- 浏览: 180926 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
枫了的红叶儿:
事务与存储过程的区别 -
黄进宝与wys:
...
Mysql事务处理 -
youshenxuzuo:
您好, 我有个问题想请教一下。关于start方法启动线程,自动 ...
java thread: run方法和john方法 -
Leisurez:
[i][u]引用[list]
[*]
[/list][/u][ ...
Hibernate的查询方式 -
Leisurez:
[flash=200,200][/flash]
Hibernate的查询方式
一、接口
1.接口中的方法默认都是public和abstract的,不管是否显式声明。
2.接口可以继承接口。
3.接口中的变量都是 public,static和final的
4.接口中不能声明静态方法
二、枚举
1.枚举类型默认继承了java.lang.Enum类,因此不能在继承其他类或enum。
2.不要实例化一个enum,因为枚举类型中的内容都是public,static和final的,没有理由去创建一个枚举类型的实例。
3.枚举类型的values()方法返回一个包含其所有内容的数组,对于枚举类型中的每个元素,ordinal()方法可以获得该元素的序号(从零开始)
4.enum中可以定义方法和数据结构,但是必须在enumeration list之后。
三、嵌套类
1.java中有四种类型的嵌套类:成员内部类(member inner class)、本地内部类(local inner class,在方法内部定义的)、匿名内部类(在方法内部定义的没有名字的local inner class)、静态嵌套类(Top - level inner classes are static inner classes that are nested at the member level of a class.)
2.内部类与其外部类是联系在一起的,不能在不依赖其外部类的情况下实例化内部类
3.成员内部类:A member inner class is defi ned at the member level of a class
(the same level as fields,methods and constructors).
(1).成员内部类可以是public或protect或private或默认的访问权限
(2).成员内部类可以继承任何类或实现任何借口
(3).成员内部类可以是abstric或final的
(4).成员内部类中不能定义静态变量或方法
(5).最重要的是,成员内部类可以访问其外部类的所有成员,包括私有成员
4.Local inner classes
(1)Local inner classes do not have an access specifier.
(2)Local inner classes cannot be declared static , nor can they declare static fields or methods.
(3)Local inner classes have access to all the fields and methods of its enclosing class(包括private的).
(4)A local inner class does not have access to the local variables of method unless those variables are final .
5.匿名内部类
(1)An anonymous inner class must either extend an existing class or implement an existing interface.
(2)The difference with anonymous inner classes is that you can create multiple instances of a local inner class within the method, but an anonymous inner class can only be instantiated one time.
6.静态嵌套类
(1).静态嵌套类不是内部类,它不能访问包含它的类的字段(field)和方法,可以不依赖其外部类(这样表达可能不够准确,因为既然不是内部类,也就无所谓外部类)的实例而被实例化。
(2).静态嵌套类与一般的类没有太多区别,除了:
--The nesting creates a type of namespace. To denote a nested class from outside its enclosing class, the nested class is prefixed with the name of the enclosing class (similar to how static fields and methods are accessed).
--Access to the nested class can be controlled by an access specifier. For example, a nested class declared as private can only be used within its enclosing class, in effect hiding it from any other classes.
--The enclosing class has access to the fields and methods of the nested class, even the private ones.
四、异常
1.java.lang.Throwable 是所有异常类的父类,其直接子类包括java.lang.Exception和java.lang.Error。
2.可以用多个catch语句块捕获异常,如果异常被一个catch块捕获,则后面的catch语句块将被忽略;如果一个catch块中的异常类型是前面catch语句块中异常类型的子类,程序将出现编译错误。
3.异常类型
Runtime exceptions:异常类型为java.lang.RuntimeException或其子类。java.lang.RuntimeException是java.lang.Exception的直接子类。
Checked exceptions:异常类型为java.lang.Exception,但不是java.lang.RuntimeException的子类。这类异常必须被处理(通过try...catch捕获或者通过throws抛出)。
Errors:类型为java.lang.Error。通常是由程序外部原因导致的错误。
理论上,所有类型的异常都可以被捕获,包括Error,但是通常捕获Error是非常困难或不可能的;而捕获runtime exception对程序设计是非常不利的,runtime exception可以通过代码优化而避免,如果捕获并处理,将无法发现程序中存在的问题,是一种隐患。
4.A try statement can contain a finally block without any catch clauses
5.也有finally语句不被执行的可能:如果try抛出了异常被catch捕获,并且在catch块中调用了System.exit终止了JVM运行,则finally语句块不被执行。
五、String
1.JVM将String对象实例保存在一个特殊的内存区域(String pool)中,可以共享。如:
String one = “today”;
String two = “today”;
if(one == two)
System.out.println(“true”);
else
System.out.println(“false”);
输出是true。
2.String对象比较时,应使用equals方法,因为并不是所有的String object都在String pool中。如:
String one = “today”;
String three = new String(“today”);
if(one == three)
System.out.println(”true”);
else
System.out.println(“false”);
The one reference points to a String object in the string pool while the three reference points to a dynamically created String object on the heap, so one and three do not point to the same instance and the output of the previous code is ”false”.
3.StringBuffer与StringBuilder二者方法完全相同,区别在于StringBuffer的方法是线程安全的,StringBuilder的方法是非线程安全的。
4.当需要对字符串进行频繁的连接操作时,使用StringBuffer或StringBuilder效率更高。因为在对String对象进行连接操作时,JVM会创建对应的临时StringBuffer对象来进行操作。
1.接口中的方法默认都是public和abstract的,不管是否显式声明。
2.接口可以继承接口。
3.接口中的变量都是 public,static和final的
4.接口中不能声明静态方法
二、枚举
1.枚举类型默认继承了java.lang.Enum类,因此不能在继承其他类或enum。
2.不要实例化一个enum,因为枚举类型中的内容都是public,static和final的,没有理由去创建一个枚举类型的实例。
3.枚举类型的values()方法返回一个包含其所有内容的数组,对于枚举类型中的每个元素,ordinal()方法可以获得该元素的序号(从零开始)
4.enum中可以定义方法和数据结构,但是必须在enumeration list之后。
三、嵌套类
1.java中有四种类型的嵌套类:成员内部类(member inner class)、本地内部类(local inner class,在方法内部定义的)、匿名内部类(在方法内部定义的没有名字的local inner class)、静态嵌套类(Top - level inner classes are static inner classes that are nested at the member level of a class.)
2.内部类与其外部类是联系在一起的,不能在不依赖其外部类的情况下实例化内部类
3.成员内部类:A member inner class is defi ned at the member level of a class
(the same level as fields,methods and constructors).
(1).成员内部类可以是public或protect或private或默认的访问权限
(2).成员内部类可以继承任何类或实现任何借口
(3).成员内部类可以是abstric或final的
(4).成员内部类中不能定义静态变量或方法
(5).最重要的是,成员内部类可以访问其外部类的所有成员,包括私有成员
4.Local inner classes
(1)Local inner classes do not have an access specifier.
(2)Local inner classes cannot be declared static , nor can they declare static fields or methods.
(3)Local inner classes have access to all the fields and methods of its enclosing class(包括private的).
(4)A local inner class does not have access to the local variables of method unless those variables are final .
5.匿名内部类
(1)An anonymous inner class must either extend an existing class or implement an existing interface.
(2)The difference with anonymous inner classes is that you can create multiple instances of a local inner class within the method, but an anonymous inner class can only be instantiated one time.
6.静态嵌套类
(1).静态嵌套类不是内部类,它不能访问包含它的类的字段(field)和方法,可以不依赖其外部类(这样表达可能不够准确,因为既然不是内部类,也就无所谓外部类)的实例而被实例化。
(2).静态嵌套类与一般的类没有太多区别,除了:
--The nesting creates a type of namespace. To denote a nested class from outside its enclosing class, the nested class is prefixed with the name of the enclosing class (similar to how static fields and methods are accessed).
--Access to the nested class can be controlled by an access specifier. For example, a nested class declared as private can only be used within its enclosing class, in effect hiding it from any other classes.
--The enclosing class has access to the fields and methods of the nested class, even the private ones.
四、异常
1.java.lang.Throwable 是所有异常类的父类,其直接子类包括java.lang.Exception和java.lang.Error。
2.可以用多个catch语句块捕获异常,如果异常被一个catch块捕获,则后面的catch语句块将被忽略;如果一个catch块中的异常类型是前面catch语句块中异常类型的子类,程序将出现编译错误。
3.异常类型
Runtime exceptions:异常类型为java.lang.RuntimeException或其子类。java.lang.RuntimeException是java.lang.Exception的直接子类。
Checked exceptions:异常类型为java.lang.Exception,但不是java.lang.RuntimeException的子类。这类异常必须被处理(通过try...catch捕获或者通过throws抛出)。
Errors:类型为java.lang.Error。通常是由程序外部原因导致的错误。
理论上,所有类型的异常都可以被捕获,包括Error,但是通常捕获Error是非常困难或不可能的;而捕获runtime exception对程序设计是非常不利的,runtime exception可以通过代码优化而避免,如果捕获并处理,将无法发现程序中存在的问题,是一种隐患。
4.A try statement can contain a finally block without any catch clauses
5.也有finally语句不被执行的可能:如果try抛出了异常被catch捕获,并且在catch块中调用了System.exit终止了JVM运行,则finally语句块不被执行。
五、String
1.JVM将String对象实例保存在一个特殊的内存区域(String pool)中,可以共享。如:
String one = “today”;
String two = “today”;
if(one == two)
System.out.println(“true”);
else
System.out.println(“false”);
输出是true。
2.String对象比较时,应使用equals方法,因为并不是所有的String object都在String pool中。如:
String one = “today”;
String three = new String(“today”);
if(one == three)
System.out.println(”true”);
else
System.out.println(“false”);
The one reference points to a String object in the string pool while the three reference points to a dynamically created String object on the heap, so one and three do not point to the same instance and the output of the previous code is ”false”.
3.StringBuffer与StringBuilder二者方法完全相同,区别在于StringBuffer的方法是线程安全的,StringBuilder的方法是非线程安全的。
4.当需要对字符串进行频繁的连接操作时,使用StringBuffer或StringBuilder效率更高。因为在对String对象进行连接操作时,JVM会创建对应的临时StringBuffer对象来进行操作。
发表评论
-
Core Java Interview Questions Answers in Finance domain
2012-02-27 11:10 10291. What is immutable object? Ca ... -
Java transient 关键字
2012-02-03 10:09 5421、transient关键字只能修饰变量,而不能修饰方法和类。 ... -
Java 序列化的问题
2012-01-17 17:39 1112【本文为转载,以做备忘,对其中的例子做了修改,原文地址:htt ... -
Java的参数传递
2012-01-16 11:41 978有人说java 参数传递在对primitive类型的参 ... -
Java 异常知识点
2012-01-12 17:00 1912一、异常的继承结构 Java异常的基类为java ... -
java thread: run方法和john方法
2012-01-11 11:33 40981、要实现多线程 ... -
java 格式化输出 printf 总结
2012-01-09 18:17 24730通过一个具体实例说明: double d = 345.67 ... -
scjp 知识点
2012-01-05 22:03 925标识符 □标识 ... -
JAVA枚举类型入门
2011-05-20 09:41 959Java 代码的两个基本的构造块是类 和接口。 ... -
JAVA中的方法覆盖/覆写的十大原则
2011-05-19 14:32 4399什么是方法覆盖 如果在子类中定义的一个方法,其名称、返 ... -
Java Map 遍历方法
2011-04-26 16:34 877第一种: Map map = new HashMap ... -
【转】程序员必知:Java代码常见的十种错误(2)
2011-03-10 15:52 1044六、常见错误6:检查new 操作的结果是否为null ... -
【转】程序员必知:Java代码常见的十种错误(1)
2011-03-10 15:48 972【IT168 技术】每一个程序员在编写代码的过程中都免不了 ... -
Java基础知识是刨根问底
2011-02-25 16:26 10201、类A实现了接口I,A能否改变I中定义的变量? 2、 ... -
Java编程题汇总备忘
2011-02-15 22:30 15351.从键盘输入一组数(用,分割),排序后输出 【分析】使用S ... -
JDK1.5/1.6新特性总结
2011-02-14 12:39 1182一、JDK1.5新特性 1、泛型(Generic) 可以在编 ... -
XML知识点备忘
2011-01-22 10:58 12841.xml名称空间通过一系 ... -
JDBC连接数据库的完整步骤
2011-01-22 00:13 8140JAVA连接数据库的方式有多种,根据所需要的不同数据库驱动分, ... -
Java IO 知识点备忘
2011-01-21 14:16 9941. java io 库采用Decorator设计模式 2. ... -
Java 试题备忘
2011-01-18 15:36 8731. Given the following class de ...
相关推荐
Java学习更是如此,知识点总结目录如下: 目录 一、 Java概述 3 二、 Java语法基础 5 数据类型 5 运算符号 14 语句 15 函数 15 方法重载(Overloadjing)与重写(Overriding) 16 数组 17 总结 18 三、 常见关键字 ...
电子备忘录包含GUI的知识和相关的监听技术,是core java基础部分的内容,对于初学的人是很适合的,希望大家多多支持啊!!!!!
用java实现备忘时钟,适合初学者,用java实现备忘时钟,适合初学者,
Java写的一个类似windows自带的日历程序,他除了可以浏览日期外,还可以在特定的时间点写备忘录,当到达该时间点时会有弹窗提示。
用JAVA编写的备忘录, 可以记录下你每天做的事情,可以查看你以前做的事情,很有帮助
JAVA程序日历源码,层次清晰,编写规范
java开发备忘录
提供公务员考试的各类公共基础知识备忘总结,具有一定的使用价值。
基于java的备忘录软件开发,还有日程管理的功能
Java设计模式,备忘录模式的Demo,具体的思想与实现有很多讲得很好的老师,我是看厉风行老师的视频学的,讲得不错,简单易懂
JavaME开发备忘.pdf
JavaD图形备忘Java多媒体PPT教案学习.pptx
CAN总线基础知识,物理层,链路层
一个自己写的备忘录程序,可以用标题和内容的形式记录一些信息,可以按照标题、记录日期、信息类型查询,导出excel数据。另外提供到期提示和闹钟功能。使用javadb嵌入式数据库,swing外观。提供Eclipse工程源代码和...
备忘录模式的示例代码和文档,学习备忘录模式的参考资料。
NULL 博文链接:https://lgsun592.iteye.com/blog/977825
java课程设计--用java写的个人备忘录管理系统
当初学习JAVA时候,敲得一个黑窗口JAVA备忘录,用的HASHMAP对数据进行增删改查。
实现备忘录基本功能,可以显示年月日日历,点击任意一日期可以写备忘录,写完保存后在点这个日期则跳出窗口说该日期有备忘录
Linux备忘手册基础知识