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 ...
随机推荐
- 依赖注入和IOC
http://www.bbsmvc.com/archiver/csharp/thread-831-1.html 本来想使用一下Ninject的,然后搜索了很久,都没找到比较详细的关于Ninject的使 ...
- IOS UI 第一篇:基本UI
1. UI 书写 最基本创建一个label 标签 写一个first rate : UILabel *label = [[UILabel alloc] initWithFrame:CGRect ...
- D11
=-=感觉今天的题目好难... 主要是没有碰到过,所以会觉得不懂怎么写.. 其实现在想想,T1,T2,T3其实都好水..T1其实没有做过还真不会,有做过的话就是个大水题了 T2找最小环..超级裸的,但 ...
- ASP.NET MVC相关
Orchard源码分析(7):ASP.NET MVC相关 概述 Orchard归根结底是一个ASP.NET MVC(以后都简称为MVC)应用,但在前面的分析中,与MVC相关内容的涉及得很少.MVC提供 ...
- Topics
Topics Introduction (starting with old devices) How to handle a new Firmware How to set up your Mac ...
- 对 Linux 新手有用的 20 个命令
你打算从Windows换到Linux上来,还是你刚好换到Linux上来?哎哟!!!我说什么呢,是什么原因你就出现在我的世界里了.从我以往的经验来说,当我刚使用Linux,命令,终端啊什么的,吓了我一跳 ...
- 一位IT牛人的十年经验之谈
1.分享第一条经验:“学历代表过去.能力代表现在.学习力代表未来.” 其实这是一个来自国外教育领域的一个研究结果.相信工作过几年.十几年的朋友对这个道理有些体会吧.但我相信这一点也很重要:“重要的道理 ...
- HTML5学习+javascript学习:打飞机游戏Service层Control层+源码
2.Service层 如前所述,Service层是Control层与Model层之间桥接的一层,它拥有所有要在屏幕上显示的实体(除了背景)的引用 我们知道,当游戏运行时,随时都可能发生碰撞,随时都可能 ...
- C语言的变量的内存分配
今晚看了人家写的一个关于C语言内存分配的帖子,发现真是自己想找的,于是乎就收藏了... 先看一下两段代码: char* toStr() { char *s = "abcdefghijkl&q ...
- 一步步学习Python-django开发-建立django数据库
上篇文章建立了一个空的网站.现在我们要准备正式我们的网站开发咯.那么开发的第一步是啥呢?当然是要确定做什么网站了.每个人的开发习惯可能不尽相同,有点可能是从前端开始设计,有的可能是从数据库开始设计(不 ...