用JAVA设计一个程序! 1、用户输入不定字符串,程序打印出用户输入的字符串的长度,并且打印出字符串信息
3个回答
展开全部
你问了好几次了,
import java.util.Scanner;
public class Du {
public static void main(String[] args) {
String input = getnInputStr();
firstApplication(input);
secondApplication(input);
}
private static void secondApplication(String input) {//第二个程序
StringBuffer sb = new StringBuffer();
for(int i = 0; i < input.length(); i++){
sb.append((int)input.charAt(i));
}
System.out.println("After encrypted string is: " + sb.toString());
}
private static String getnInputStr() {
System.out.print("Please input some string: ");
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
return str;
}
private static void firstApplication(String str) {//第一个程序
System.out.println("The length of inputed string is: " + str.length());
System.out.println("Huiwen of inputed string is: "+ new StringBuffer(str).reverse().toString());
}
}
--------------------
Please input some string: abdsd12345xyz
The length of inputed string is: 13
Huiwen of inputed string is: zyx54321dsdba
After encrypted string is: 97981001151004950515253120121122
import java.util.Scanner;
public class Du {
public static void main(String[] args) {
String input = getnInputStr();
firstApplication(input);
secondApplication(input);
}
private static void secondApplication(String input) {//第二个程序
StringBuffer sb = new StringBuffer();
for(int i = 0; i < input.length(); i++){
sb.append((int)input.charAt(i));
}
System.out.println("After encrypted string is: " + sb.toString());
}
private static String getnInputStr() {
System.out.print("Please input some string: ");
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
return str;
}
private static void firstApplication(String str) {//第一个程序
System.out.println("The length of inputed string is: " + str.length());
System.out.println("Huiwen of inputed string is: "+ new StringBuffer(str).reverse().toString());
}
}
--------------------
Please input some string: abdsd12345xyz
The length of inputed string is: 13
Huiwen of inputed string is: zyx54321dsdba
After encrypted string is: 97981001151004950515253120121122
展开全部
public static void main (String[] args)
{
java.uti.Scanner in = new java.util.Scanner (System.in).useDelimiter(";") ;
String ret = in.next() ;
System.out.println ("get the length is: " + ret.length() + " get the string is: "+ ret);
}
{
java.uti.Scanner in = new java.util.Scanner (System.in).useDelimiter(";") ;
String ret = in.next() ;
System.out.println ("get the length is: " + ret.length() + " get the string is: "+ ret);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
。。
import java.io.*;
public class Length {
public static void main(String[] args) throws IOException{
BufferedReader indata=new BufferedReader(new InputStreamReader(System.in));
String str=indata.readLine();
System.out.println("字符串信息:"+str+"\n字符串长度:"+str.length());
}
}
import java.io.*;
public class Length {
public static void main(String[] args) throws IOException{
BufferedReader indata=new BufferedReader(new InputStreamReader(System.in));
String str=indata.readLine();
System.out.println("字符串信息:"+str+"\n字符串长度:"+str.length());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询