码迷,mamicode.com
首页 > 编程语言 > 详细

[Java]class00

时间:2020-10-31 02:26:05      阅读:18      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!