waltermilner

Untitled

Feb 17th, 2019
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1.   public static void main(String[] d) {
  2.     System.out.println("working");
  3.     // I started this with command line arguments "one two three", so
  4.     System.out.println(d.length);
  5.     // d is an array with three elements
  6.     String S = " rayhan";
  7.     d[1] = S;
  8.     System.out.println(d[1]);
  9.     // if I had started it with no command line arguments, d ould have had no elements,
  10.     // and d[1]=S would have been an array bounds exception.
  11.     // I can always do this
  12.     d=new String[3];
  13.     d[1] = "hello";
  14.     System.out.println(d[1]); // hello
  15.     // but it makes almost no sense
  16.  
  17.   }
Advertisement
Add Comment
Please, Sign In to add comment