我是靠谱客的博主 默默小白菜,这篇文章主要介绍The 3rd day learning Java,现在分享给大家,希望可以做个参考。

learning package & import: 

key points (some are different with C/C++ coding): 

1. the main class name (if public) has to be consistent with the class file name:


Thus needs to rename the mainclass to be example_1_1, i.e., public class example_1_1{

2. wrong: [import java.io],  correct: [import java.io.*]

3. must have ";" after "import" statements, e.g., [import java.io.*;]

4. function names/methods are all case sensitive

5. prompt  to use -Xlint:unchecked for detail information if the code contains unchecked or unsafe operations (but seems actually unnecessary)



package: class container, organize, reusable, maintainability, encapsulation, modularity, defining hierarchical directory structure, up to 1 per file, reverse domain name, equate to directory structures, should be lowercase, separated by underscores.

import java.io.*;
import java.util.ArrayList;

public class example_1_1{
	public static void main(String[] args){
		Console console = System.console();
		String planet = console.readLine("nEnter your favorite planet:");
		ArrayList planetlist = new ArrayList();
		planetlist.add(planet);
		planetlist.add("Gliese 581 c");
		System.out.println("nTwo cool planets:" + planetlist);
	}
}




最后

以上就是默默小白菜最近收集整理的关于The 3rd day learning Java的全部内容,更多相关The内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部