Java learning notes (1):Basic Knowlege points
Basic Knowlege points:
1: it's necessary that there is only one public class in per .java file
2: .java file name should better to same as class name
3: when set the environment variable CLASSPATH, you should make sure the '.' path can't be lack of.
4: java is case sensitive, including .java file name , class name, variable name, method name and so on.
5: JVM uses automatic garbage collection machanism. It just collects memory source, not contains physical source, such as database connection, disk IO. You can invoke a collection through call static method System.gc().
6:Java is strong-type language, the variable shouble be declared firstly and then you can use it. ② the vairable only can accept the value which type is consistent with itself.
7: /** */ is used to add document annotation for java. javadoc command can export the code API document.
8: use '...' follow method parameter type, means has at least one parameter or more parameter. It equals type array type[]. it's similar with params in C#
9. In java, lamda expression use '->' symbol
10. From java 7, switch statement was allow to use String type, before just includes byte, int, char, shot four type.
11.For java, object instance can access the class static method or static field. but in c#, That's illegal.
12. For java, the package is similar with namespace in c#
13. for classes they belongs to same packege, don't have to at the same directory. That means there can be several packages with same name, but these packages should at different directory. And .class file should at the directory which name is same with its package name.
14. in java, 'instanceof' keyword equals 'is' in C#; there isn't keyword like as 'as'.
15. In Java, support initialization block , don't in c#.
public class A
{
{ ... block }
}
note: the execute order is that: create class object, initialize block, initialize field, constructor
if all class object have same logic, or initialize code, we can use static initialization block
16. In java, final keyword is same as sealed in c#.
17. the relationship of basic type with their packaged class

when convert between basic type with packaged class, system will boxing or unboxing automatically.
18. for value type and reference type which are defined by 'final' keyword', difference is following:
1. final value type can't be changed or modified anymore.
2. final reference type' reference which is pointer address is can't changed, but the object fields can be modified or changed.
Note: it's same as 'readonly' key word and 'const' key word in c#.
19. Object reference:
1. StrongReference ---- when system collect garbage, the object will not be recycled.
2. WeakReference ---- when system collect garbage, the object will be recycled compulsively.
3. PhatomReference ----- the object will be recycled compulsively. it can't get object address reference use PhatomReference. it just to use to trace the object.
4.SoftReference ------ when system collect garbage, if the memory is not enough , the object will be recycled compulsively.
Note: it's alse same as WeakReference in c#
Java learning notes (1):Basic Knowlege points的更多相关文章
- Mybatis Learning Notes 1
Mybatis Learning Notes 主要的参考是博客园竹山一叶的Blog,这里记录的是自己补充的内容 实体类属性名和数据库不一致的处理 如果是实体类的结果和真正的数据库的column的名称不 ...
- rt-thread learning notes
rt-thread learning notes 2018-01-15 > 001 具有相同优先级的线程,每个线程的时间片大小都可以在初始化或创建该线程时指定 rt_thread_t rt_th ...
- Java Learning Path(四) 方法篇
Java Learning Path(四) 方法篇 Java作为一门编程语言,最好的学习方法就是写代码.当你学习一个类以后,你就可以自己写个简单的例子程序来运行一下,看看有什么结果,然后再多调用几个类 ...
- Java Learning Path(五)资源篇
Java Learning Path(五)资源篇 1. http://java.sun.com/ (英文) Sun的Java网站,是一个应该经常去看的地方.不用多说. 2.http://www-900 ...
- Java Learning Path(三)过程篇
Java Learning Path(三)过程篇 每个人的学习方法是不同的,一个人的方法不见得适合另一个人,我只能是谈自己的学习方法.因为我学习Java是完全自学的,从来没有问过别人,所以学习的过程基 ...
- Java Learning 001 新建一个Java工程 HelloWorld程序
Java Learning 001 新建一个Java工程 HelloWorld程序 Step 1 . 在Eclipse 软件里,点击: File -> New -> Java Projec ...
- Java Learning 000 搭建开发环境
Java Learning 000 搭建开发环境 你需要两个软件: * JDK (Java Develop Kit :Java开发工具包) * eclipse (eclipse 集成开发环境软件) 安 ...
- Rust learning notes
Rust learning notes Rust Version 1.42.0 $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs ...
- Coursera, Machine Learning, notes
Basic theory (i) Supervised learning (parametric/non-parametric algorithms, support vector machine ...
随机推荐
- 什么是gulp
gulp:入门简介 本文是gulp的入门级介绍,主要内容包括什么是gulp,gulp与grunt有什么区别,gulp可以解决grunt存在的哪些问题,以及一个简单的说明例子. 什么是gulp gu ...
- IOS UI 第十一篇: UITABLEVIEW
DIY a tableviewcell : - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *) ...
- [google面试CTCI] 2-3 只给定链表中间节点指针,如何删除中间节点?
[链表] Q:Implement an algorithm to delete a node in the middle of a single linked list, given only acc ...
- HDU 4618 - Palindrome Sub-Array(2013MUTC2-1008)(DP)
d(i,j,k)表示左上角坐标为(i,j),k为正方形边长 d(i,j,k)=1,如果d(i+1,j+1,k-2)=0,且上下两个外围的相等且回文,左右两个外围的相等且回文:否则d(i,j,k)=0 ...
- linux下使用kpartx挂载虚拟文件系统
在linux中,如果映像文件(.img)含有分区表的话,那么用losetup这个程序来加载文件系统就有点力不从心了.因为losetup只能加载无分区的文件系统映像文件.不过有一个好东西配合losetu ...
- QSQL导出mapfile和mapfile中PostGIS连接的一点心得
昨天弄QSQL导出mapfile,一直遇到下图的错误 原因是QGIS在渲染图层时候使用了新的符号,在图层上右键-属性,如下图将符号修改就OK了 然后我尝试使用QGIS连接本机PostGIS数据,结果老 ...
- php 数组合并方法
$new = array(); if ($relateddepartmentsnew) { foreach ($relateddepartmentsnew as $relatK=>$relatV ...
- Citrix 服务器虚拟化之四 Xenserver资源池
Citrix 服务器虚拟化之四 Xenserver资源池 台主机,尽管这种限制没有执行.池总是至少有一个物理节点,称为主.只有主节点公开管理界面(使用XenCenter和XenServer命令行界面 ...
- GestureDetector学习之左右滑动,上下滑动屏幕切换页面
要实现滑屏等触发事件,视情况而定: 如果实现的触屏或者手势效果较多,则使用第一种方法,实现OnGestureListener 接口(参考OnGestureListener): 如果只是实现较少的效果, ...
- 使用DOM4J解析XML文档,以及使用XPath提取XML文档
使用DOM4J解析XML文档 需要首先下载DOM4J工具包.这是个第三方工具包 在使用DOM4J解析的时候需要导入 DOM4J的JAR包 下载DOM4J工具包->在MyEclipse中新建lib ...