- Do not define a instance variable in a controller class. It affects the performance.
- Prefer Concat method for the String Concatenation instead of "+="
- Do not call a method in the loop to check the condition.
Java Chips
Sunday, June 19, 2011
Java Tips
Thursday, May 26, 2011
Exceptions
Only Checked Exception should be thrown in Java i.e we can instruct the java compiler to handle that. Other Exceptions are Runtime Exception which we don need to handle that. Checked Exception also includes the User Defined Exception.
Checked Exception:
These exception are the object of the Exception class or any of its subclasses except Runtime Exception class. These condition arises due to invalid input, problem with your network connectivity and problem in database.java.io.IOException is a checked exception. This exception is thrown when there is an error in input-output operation. In this case operation is normally terminated.
List of Checked Exceptions are:
1. ClassNotFound
2. Instantiation
3.Illegal Access
4. Not Such Method
Unchecked Exceptions:
These Exception arises during run-time ,that occur due to invalid argument passed to method. The java Compiler does not check the program error during compilation
List of Unchecked Exceptions:
1. Arithmetic Exception
2. Class Cast Exception
3. Array Store Exception
4. Null Pointer Exception
Note: We can design the code in such a way to handle the Runtime Exception also. But it will degrade the Performance. That's why we are concentrating only on Compile time Exceptions.
Subscribe to:
Posts (Atom)