what are the wrapper classes in java code example
Example 1: wrapper classes in java ebhor.com
public class CommandLineArguments {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int sum = a + b;
System.out.println("Sum is " + sum);
}
}
Example 2: primitive vs wrapper classes in java
Differences:
1. Wrappers classes are object
2. null can only be assigned to classes
3. Wrapper class does have methods
4. Primitives does have default values
default value of primitives:
byte, short, int, long ==> 0
float, double ==> 0.0;
boolean ==> false;
char ==> space
5. Default values of wrapper class: null