作者NOtWorThy (骇客技术去哪学?)
看板java
标题[问题] 新手一问 关於语法
时间Wed Mar 4 23:48:55 2009
1.
import java.util.Scanner;
public class New
{
public static void main(String args[ ])
{
Scanner scanner = new Scanner(System.in);
System.out.printf("Hello!!") ;
System.out.println();
System.out.printf("enter a number:");
System.out.printf("Oh! I get a number %d!!\n", scanner.nextInt());
System.out.println("You are ?");
System.out.printf("Hello, %s\n", scanner.next());
}
}
/* JAVA中似乎再让使用者输入前不需宣告变数及形态,那如此他要如何知道我
输入多少变数? 如:在enter a number:後面我输入整数玩在输入字元字串在输入浮点数
...,他要如何记忆??如果我输入两次整数那下一行输出结果要输出哪个呢?*/
2.
import java.io.*;
public class New {
public static void main(String[] args) throws IOException
{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
/* 上面这行是类似C的别名吗?还是?? */
System.out.print("请输入一列文字: ");
String text = buf.readLine(); /* 看不懂 ~"~ */
System.out.println("您输入的文字: " + text); /*位什麽是+?? */
}
}
抱歉我是新手
没书
只有在网路上自学
但是他的范例中 很多都没讲原因 跟做注解
所以学起来雾煞煞
烦请高手不吝解析
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.91.18