day07-匿名对象的说明
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.inmind.scanner01;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/*
|
||||
匿名对象:没有名字的对象
|
||||
匿名对象的使用场景:当一个对象只要被使用一次,可以使用匿名对象来简单实现
|
||||
*/
|
||||
public class Demo04 {
|
||||
public static void main(String[] args) {
|
||||
//只接收一个整数
|
||||
/*Scanner sc = new Scanner(System.in);
|
||||
int i = sc.nextInt();*/
|
||||
|
||||
int i = new Scanner(System.in).nextInt();
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user