java 笔试题 字符串旋转
2024-10-19 09:33:17
package com.shb.java;
/**
* 取出第一个重复的字符
* @author shaobn
* @date 2016-9-28
* @package_name com.shb.java
*/
public class Demo10 { /**
* @param args
* @date 2016-9-28
* @author shaobn
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// findFirstRepeat("wqyqwyer23tdd",11);
reverseStr("hello",2);
}
// /**
// * 实现方法
// * @param str
// * @param n
// * @date 2016-9-28
// * @author shaobn
// */
// public static void findFirstRepeat(String str,int n){
// char[] ch = str.toCharArray();
// out: for(int i=0;i<n-1;i++){
// for(int j = i+1;j<n;j++){
// if(ch[i]!=ch[j]){
// continue;
// }else {
// System.out.println(ch[i]);
// break out;
// }
// }
//
// }
//
//
// }
/**
* 字符串的旋转 前n个字符排到后边,而后边的往前移动
* @param str
* @param n
* @date 2016-9-29
* @author shaobn
*/
public static void reverseStr(String str,int n){
String string = str.substring(0, n+1);
String string2 = str.substring(n+1);
String string3 = string2.concat(string);
System.out.println(string3);
} }
最新文章
- appium实现截图和清空EditText
- PHP运算符
- javascript模块化详解
- IIS6的SSL配置,如何配置SSL到登陆页,如何将SSL证书设置成受信任的证书
- Linux学习笔记(6)-工作管理
- IIS tomcat共用80端口解决一个IP多个域名:使用Nginx反向代理方式使两者兼容
- MongoDB(三)——CRUD
- OC-之AFNetworking
- Shell:进程的层级关系
- LearningDocker--Chapter3--Building images
- 启动链码报rpc error: code = Unimplemented desc = unknown service protos.ChaincodeSupport start error
- 9. VIM 系列 - YouCompleteMe 实现代码补全
- tar解压指定文件
- Anatomy of a Database System学习笔记 - 查询
- F#.NET周报 2018第34周-Ionide下载量100万
- bootstrap table 前端搜索
- C语言概述
- 判断Mouse事件源类型
- 北风网VIP6级学习视频地址
- hadoop(二)hadoop集群的搭建