I am trying to self teach myself to learn Java programming. Will someone please help me with this program. I getting confused about encapsulating. If I am comprehending what I am reading in my Java book, encapsulate means to start my properties with private so they can't be change by the client. Am I correct so far? Also, I know string means, whats inside the " ". With that said, will someone tell me how to go about coding the rest of this program contain in this post? When I run the program, I get error message:
/**Write a program that creates Boolean, Character, Byte, Short, Integer, Long, Float, and Double objects to encapsulate eight values supplied as command-line arguments. Display the string equivalent of each objects.
*/
2nd question: When I use the word properties as a designation in my question above, can that designation be interchangeable with the word variable?
HTML:
java.lang.ArrayIndexOutOfBoundsException: 0
at EightTypes.main(EightTypes.java:17)
/**Write a program that creates Boolean, Character, Byte, Short, Integer, Long, Float, and Double objects to encapsulate eight values supplied as command-line arguments. Display the string equivalent of each objects.
*/
HTML:
public class EightTypes {
public static void main(String args[ ]) {
Boolean bool = Boolean.valueOf(args[0]);
Character c = new Character(args[1].charAt(0));
Byte b = Byte.valueOf(args[2]);
Short s = Short.valueOf(args[3]);
Integer i = Integer.valueOf(args[4]);
Long l = Long.valueOf(args[5]);
Float f = Float.valueOf(args[6]);
Double d = Double.valueOf(args[7]);
System.out.println(bool);
System.out.println(c);
System.out.println(b);
System.out.println(s);
System.out.println(i);
System.out.println(l);
System.out.println(f);
System.out.println(d);
}
}
2nd question: When I use the word properties as a designation in my question above, can that designation be interchangeable with the word variable?