Easy to ignore in Basic Java

Source: Internet
Author: User

 

1. In Java exception handling, the error exception generally does not need to be captured by the programmer.

 

2. The runtimeexception statement must be encapsulated in the try statement. 3.

 

3. Differences between arraylist and vector: there is basically no difference in usage, but in multi-threaded programming, the vector thread is safe.

 

4 set/LIST/map: all inherit from the collection interface, where list is ordered,

 

The 5most list has the characteristics of a linked list, so it is also ordered. It is suitable for sequential search and regular addition and deletion operations. arraylist is suitable for random search.

 

In 6jdbc (class. forname (sun. JDBC. ODBC. jdbcodbcdriver); connection conn = drivermanager. getconnection (URL, user, PWD) Statement ST = con. createstatement (); preparedstatement PSTM = con. preparedstatement (SQL ). it is not hard to understand that preparedstatement must be precompiled, so parameters must be included.

 

7. The resultsetmetadata (resultset rs = st.exe cutequery (SQL); resultsetmetadata RSSD = Rs. getmetadata ();)

 

8 (5.5 belongs to the double type in Java: Float F = 5 + 5.5 is not compiled.

 

9 (Super) calls the constructor of the parent class. If the subclass overrides the method of the parent class, it must call the method of the parent class: Super. methodname ();

 

10string constructor does not contain new string (INT value). stringbuffer is automatically generated when the string overload operator +.

 

11 In switch (value), the value type can be byte/short/INT/Char.

 

The hexadecimal format must start with ox and the octal format must start with O.

 

13static cannot access non-static.

 

14 private/protected/public/Default: private class. Default: class of the same package, class of the same package of protected and subclass of different packages, all classes of public.

 

15interface method type: Public/Default

 

16 (exception e) Description. When an exception is caught in the try {} segment, the JVM automatically runs the following statement: Throw new exception. It is not difficult to understand why e can be used without instantiation.

 

17 Class A {public int getnum () {return 5 ;}} Class B extends a {public int getnum () {return 4 ;}public static void main (string [] ARGs) {A = new B (); system. out. println (. getnum ()} result: 4

 

18 char CH = 'A', which should be two bytes. It is the same as 'In char CH =.

 

19 Note = the difference between = and equals is = ratio object, equals ratio content.

 

20 Java class is upward, that is, any class can use the objec class method, because any class inherits from the object.

 

21 Class A {static int A; public static void main (string [] ARGs) {system. out. println (a) ;}} result 0; Class B {public static void main (string ARGs []) {int A; system. out. println (a) ;}} is not compiled. the error is that A is not initialized.

 

22 inputstream in = new inputstream (system. In); outputstream out = new outputstream (system. out ).

 

23try cannot be used separately.

 

24 char [] [] CH = new char [5] [] is the same as method. It cannot be found in C.

 

25finally is usually used to release resources. After try, it can be directly connected to finally without catch.

 

26 when declaring attributes, it is best to use private. When inheriting, It inherits everything from the parent class, not just the public and default/protected methods.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.