或在上传的文件中下载。
输出字符串
public class PutOutString
{
public static void main(String[] args) throws InterruptedException
{
String s = "asdfdfwefwgggvbcvbcv";
for (int i = 0; i < s.length(); i++)
{
System.out.print(s.charAt(i));
//Thread.sleep(1000);//输一个停一秒
}
}
}
字符输入输出
package examWithinAWeek;
import java.io.*;
public class InPutChar{
public static void main(String[] args){
char c;
System.out.println("请输入一个字符:");
c=(char)System.in.read();
System.out.println("你输入的字符是:"+c);
}
}
字符(串)输入输出
package examWithinAWeek;
import java.io.*;
public class InPutString{
public static void main(String[] args){
String s="";
System.out.println("请输入一个字符:");//只读取一个字符,按字符(char)读取.
Reader in=new InputStreamReader(System.in);
try
{
System.out.println("你输入的字符串是:"+(char)in.read());
}
catch(IOException e)
{
System.out.println("出现一个异常");
}
System.out.println("请输入一串字符:");//读取一串字符,按字符串(String)读取
BufferedReader newin = new BufferedReader(new InputStreamReader(System.in));
try
{
s=newin.readLine();
System.out.println("你输入的字符串为:"+s);
}
catch(IOException e)
{
System.out.println("发生异常!");
}
}
}
字符(串)输入输出(精简)
package examWithinAWeek;
import java.io.*;
public class InPutString{
public static void main(String[] args)throws IOException{
System.out.println("请输入一个字符:");//只读取一个字符,按字符(char)读取.
Reader in=new InputStreamReader(System.in);
System.out.println((char)in.read());
System.out.println("请输入一串字符:");//读取一串字符,按字符串(String)读取
BufferedReader newin = new BufferedReader(new InputStreamReader(System.in));
System.out.println(newin.readLine());
}
}
整型输入输出
import java.util.*;
public class PrintInt{
public static void main(String[] args){
Scanner p=new Scanner(System.in);
int a=p.nextInt();
System.out.print(a);
}
}
[此贴子已经被作者于2007-11-17 15:36:03编辑过]
----------------解决方案--------------------------------------------------------
好,学习中
----------------解决方案--------------------------------------------------------
呵呵,我初学,对这基本问题很苦恼,所以总结了一下。。。。。。
----------------解决方案--------------------------------------------------------