[Java]class00

2021-03-21 15:24

阅读:360

标签:int   war   NPU   throws   ann   erro   pre   bre   txt   

Season.java

package class00;

public enum Season {
	SPRING,SUMMER,FALL,WINTER
}

TestZero.java

package class00;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class TestZero{
	public static void main(String[] args) throws FileNotFoundException {
		TestZero myTestZero=new TestZero();
		
		myTestZero.testFileScan();
		myTestZero.testConsoleScan();
		myTestZero.testEnmuSeason(Season.WINTER);
		myTestZero.testBigDecimal();
		myTestZero.testChar();
	}
	public void testEnmuSeason(Season type) {
		switch(type) {
		case WINTER:
			System.out.println("Winter is coming!");
			break;
		case SPRING:
			System.out.println("Spring is warm!");
			break;
		case SUMMER:
			System.out.println("Summer is hot!");
			break;
		case FALL:
			System.out.println("Fall is cool!");
			break;
		default:
			System.out.println("input error!");
		}
	}
	public void testFileScan() throws FileNotFoundException {
		File myFile=new File("D:\\mesrc\\java_eclipse\\file\\testfile.txt");
		Scanner myIn=new Scanner(myFile);
		while(myIn.hasNext()) {
			System.out.println(myIn.nextLine());			
		}
		myIn.close();
	}
	public void testConsoleScan() {
		Scanner myIn=new Scanner(System.in);
		String myStr1=myIn.nextLine();
		System.out.println("str1:"+myStr1);
		myIn.close();
	}
	public void testBigDecimal() {
		//not use int or double
		//use BidDecimal
		//todo
	}
	public void testChar() {
		char c1=‘中‘;
		System.out.print(c1);
	}
}

[Java]class00

标签:int   war   NPU   throws   ann   erro   pre   bre   txt   

原文地址:https://www.cnblogs.com/lunarwhite/p/13904298.html


评论


亲,登录后才可以留言!