文章目录
package LXT;
import java.util.Scanner;
public class lxt1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String password = "12345";
System.out.println("********欢迎来到中国银行********");
for (int i = 0; i < 5; i++) {
System.out.println("请输入密码:");
String pwd = input.next();
if (pwd.equals(password)) {
System.out.println("登录成功!");
break;
} else {
if (i==4) {
System.out.println("输入密码错误超过5次账户锁定");
} else {
System.out.println("您还有" + (4-i) + "次机会");
}
}
}
}
}
package LXT;
public class lxt2 {
public static void main(String[] args) {
System.out.println(String.join("_",String.valueOf("youAreWelcome".charAt(0)).toUpperCase().concat("youAreWelcome".substring(1).toLowerCase()).split("")));
}
}
package LXT;
public class lxt3 {
public static void main(String[] args) {
String z = "我爱你";
String result = "";
for (int i = z.length()-1; i >= 0; i--) {
result += z.charAt(i);
}
System.out.println(result);
}
}
package LXT;
import java.util.Scanner;
public class lxt4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入字符串:");
String line1 = input.next();
System.out.println("请输入要找的字符串:");
String line2 = input.next();
int count = getLine2InLine1Count(line2,line1);
System.out.println("中国个数为: " + count);
}
public static int getLine2InLine1Count(String line2,String line1) {
int count = 0;
int index = 0;
while ((index = line1.indexOf(line2)) != -1) {
count++;
line1 = line1.substring(index + line2.length());
}
return count;
}
}
package LXT;
import java.util.Scanner;
public class lxt5 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入字符串: ");
String str = input.next();
String[] strArr = str.split(" ");
for (int i = 0; i < strArr.length; i++) {
StringBuffer mo = new StringBuffer(strArr[i]);
mo = mo.reverse();
System.out.println(mo);
}
}
}
package LXT;
public class lxt6 {
public static void main(String[] args) {
StringBuffer str = new StringBuffer();
str.append("int[] arr = {33,22,55,11,66}");
str.delete(str.indexOf("i"), str.indexOf("a"));
str.replace(str.indexOf(" "), str.indexOf("}"), "[33, 22, 55, 11, 66]");
str.deleteCharAt(str.indexOf("}"));
System.out.println(str);
System.out.println(arrayToString(new int[] {33,22,55,11,66}));
}
public static String arrayToString(int[] arr) {
String result = "";
result += "arr[";
for (int i = 0; i < arr.length; i++) {
if (i == arr.length - 1) {
result += arr[i];
} else {
result += arr[i] + ", ";
}
}
result += "]";
return result;
}
}
package LXT;
import java.util.Arrays;
import java.util.Scanner;
public class lxt7 {
@SuppressWarnings("resource")
public static void main(String[] args) {
String line = new Scanner(System.in).next();
System.out.println(sortString(line));
}
public static String sortString(String str) {
byte[] bys = str.getBytes();
Arrays.sort(bys);
return new String(bys);
}
}