-
Java has a two-fold type system :
- 1- primitives such as int, boolean
- 2- reference types such as Integer, Boolean
-
Type primitives size reference size boolean 1 bit 128 bits byte 8 bit 128 bit short, char 16 bit 128 bit int, float 32 bit 128 bit long, double 64 bit 192 bit - We can see either that single-element arrays of primitive types are almost always more expensive (except for long and double) than the corresponding reference type.
-
- The performance of a Java code is quite a subtle issue, it depends very much on the hardware on which the code runs, on the compiler that might perform certain optimizations, on the state of the virtual machine, on the activity of other processes in the operating system
- As we have already mentioned, the primitive types live in the stack while the reference types live in the heap. This is a dominant factor that determines how fast the objects get be accessed.
-
- the primitive types may acquire values only from their domains, while the reference types might acquire a value (null) that in some sense doesn't belong to their domains.
- when a primitive type variable has a value that is equal to its type default one, we should find out whether the variable has been really initialized.
- There's no such a problem with a wrapper class variables since the null value is quite an evident indication that the variable hasn't been initialized.
-
-
On the other hand, current Java language specification doesn't allow usage of primitive types in the parametrized types (generics), in the Java collections or the Reflection API.
-
When our application needs collections with a big number of elements, we should consider using arrays with as more “economical” type as possible, as it's illustrated on the plot above.
-
-
- An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.
- Creating an exception object and handing it to the runtime system is called throwing an exception.
- The set of possible "somethings" to handle the exception is the ordered list of methods that had been called to get to the method where the error occurred. The list of methods is known as the call stack
- The runtime system searches the call stack for a method that contains a block of code that can handle the exception. This block of code is called an exception handler.
-
- 1- the checked exception. These are exceptional conditions that a well-written application should anticipate and recover from.
- 2- the error. These are exceptional conditions that are external to the application, and that the application usually cannot anticipate or recover from.
- 3- the runtime exception. These are exceptional conditions that are internal to the application, and that the application usually cannot anticipate or recover from. These usually indicate programming bugs, such as logic errors or improper use of an API.
-
Objects of type Scanner are useful for breaking down formatted input into tokens and translating individual tokens according to their data type.





