| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 606 人关注过本帖
标题:DONE整型,字符,字符串的输入和输出 整理。
只看楼主 加入收藏
zzxwill
Rank: 1
等 级:新手上路
帖 子:398
专家分:0
注 册:2007-8-15
收藏
 问题点数:0 回复次数:2 
DONE整型,字符,字符串的输入和输出 整理。

或在上传的文件中下载。

POt1duhS.rar (5.15 KB) 整型,字符,字符串的输入和输出 整理。



输出字符串

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编辑过]

搜索更多相关主题的帖子: 整型 DONE 字符 输出 输入 
2007-11-17 14:05
netstriker
Rank: 1
等 级:新手上路
威 望:1
帖 子:257
专家分:0
注 册:2007-3-24
收藏
得分:0 
  好,学习中
2007-11-17 14:28
zzxwill
Rank: 1
等 级:新手上路
帖 子:398
专家分:0
注 册:2007-8-15
收藏
得分:0 
回复:(netstriker) 好,学习中

呵呵,我初学,对这基本问题很苦恼,所以总结了一下。。。。。。


一分耕耘,一分收获。
2007-11-17 15:03
快速回复:DONE整型,字符,字符串的输入和输出 整理。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015449 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved