如何输入字符串,并输出
如何输入字符串,并输出或者赋值给变量
------解决方案--------------------Scanner sc = new Scanner(System.in);
String str = sc.next();
System.out.println(str);
------解决方案-------------------- InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
try{
System.out.println(br.readLine());
}catch(Exception e){}
------解决方案--------------------import java.io.*;
class Test {
public static void main(String args[]) {
char ch[]=new char[60];
int i=0,j;
System.out.print( "please input: ");
/*请输入字符串,直到回车结束*/
while( (ch[i]=(char)System.in.read())!= '\n ')
i++;
/*输出字符串*/
for(j=0;j <=ch.length-1;j++)
System.out.print(ch[j]);
}
}