JAVA中如何输入数据

kgd00544 2010-04-24 11:37:17
在C中用SCANF
那么在JAVA中如何实现
最好举行下例子
...全文
869 25 打赏 收藏 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
caodongfang126 2012-11-05
  • 打赏
  • 举报
回复
Scanner input = new Scanner(System.in); String str = input.nextLine(); 直接用咋不行呀?
zuoguodang 2010-05-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 iori200908 的回复:]
Scanner sc = new Scanner(System.in);
System.out.println("请输入内容:");
String str = sc.nextLine();
System.out.println("您输入的内容为:" + str);
[/Quote]
或者使用System.in
zhaowh10 2010-05-07
  • 打赏
  • 举报
回复
学习了,顶顶
kgd00544 2010-05-07
  • 打赏
  • 举报
回复
谢谢大家的帮忙了
liujiayu7344667 2010-04-27
  • 打赏
  • 举报
回复
package us//包名
import java.util.Scanner;
class answer{//类型
public static void main(string[] args)
{
string anser="";//声明接收变量
Scanner sc = new Scanner(System.in);
system.out.println("请输入答案:");//弹出对话框
anser =sc.next();
system.out.println("你的回答是"+anser);
}
}
lifeng350715332 2010-04-27
  • 打赏
  • 举报
回复
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入一个数:");
suiyuefuchen 2010-04-24
  • 打赏
  • 举报
回复

package TestShuru;

import java.io.*;

public class TestShuru {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = "";
while((str = br.readLine())!=null){
System.out.println("输入结果是:"+str);
}
}
}


楼主可以导入代码看看;
luomf 2010-04-24
  • 打赏
  • 举报
回复
其实都一样
sfli_g 2010-04-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zfq642773391 的回复:]

Java code
String str;
int a;
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入一个数:");
str=buf.readLine();
……
[/Quote]
、、、、
zfq642773391 2010-04-24
  • 打赏
  • 举报
回复
    String str;
int a;
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入一个数:");
str=buf.readLine();
a=Integer.parseInt(str);
System.out.println("输入的数为:"+a);
libRA_kin 2010-04-24
  • 打赏
  • 举报
回复
还有一种就是用IO流
iori200908 2010-04-24
  • 打赏
  • 举报
回复
Scanner sc = new Scanner(System.in);
System.out.println("请输入内容:");
String str = sc.nextLine();
System.out.println("您输入的内容为:" + str);
lghehe 2010-04-24
  • 打赏
  • 举报
回复
用io那块的,很简单,我也是学完c学java的,可以用Scanner
Mars_Ma_OK 2010-04-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 iori200908 的回复:]
Scanner sc = new Scanner(System.in);
System.out.println("请输入内容:");
String str = sc.nextLine();
System.out.println("您输入的内容为:" + str);
[/Quote]

up,接收控制台的数据.最好在dos下面运行..
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 bao110908 的回复:]
http://blog.csdn.net/bao110908/archive/2008/02/20/2108930.aspx
[/Quote]

带头大哥 2010-04-24
  • 打赏
  • 举报
回复
1楼和3楼都是非常标准的方法
luomf 2010-04-24
  • 打赏
  • 举报
回复
顶1楼或者3楼
renjianguokeivor 2010-04-24
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 suiyuefuchen 的回复:]
Java code

package TestShuru;

import java.io.*;

public class TestShuru {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new Input……
[/Quote]
bijianyue88 2010-04-24
  • 打赏
  • 举报
回复
雷锋们 ,不错!!!!!
yansue77 2010-04-24
  • 打赏
  • 举报
回复
一楼的对
加载更多回复(5)

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧