我是靠谱客的博主 默默小白菜,最近开发中收集的这篇文章主要介绍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 3rd day learning Java所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部