package hello;
import java.util.Scanner;//Scanner is in java.util
public class Hello
{
public static void main(String[] args)
{
System.out.println("please set in a string ");
//creat a Scanner
Scanner scanner=new Scanner(System.in);//new Scanner(System.in)是创建一个Scanner类型的对象,语法Scanner scanner 声明scanner是一个Scanner类型的变变量
String name=scanner.next();
System.out.println(name);
}
}
//计算圆的面积从控制台输入数据
package hello;
import java.util.Scanner;
public class Hello
{
public static void main(String[] args)
{
double area;
//Creat a scanner
Scanner scanner=new Scanner(System.in);
//让用户输入数据
System.out.println("请输入圆的半径");
int r=scanner.nextInt();
area=r*r*3.14;
System.out.println("面积是:"+area);//这里的加号是字符串连接符
}
}