Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interesting syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "interesting syntax" Watch "interesting syntax" New topic

interesting syntax

Leonildo Campos
Ranch Hand

Joined: Jun 02, 2003
Posts: 33
We can do it in java:
public class Sample {
public static void main(String [] args) {
int index = 1;
String name = new String[] {"Sonia", "Leonildo", "Lisa"} [index] ;
System.out.println("My name is " + name);
this code produces the output:
% java Sample
My name is Leonildo
**Be careful with that on exam.**
Brian Joseph
Ranch Hand

Joined: May 16, 2003
Posts: 160
I would like to see a page on all the various ways you can create arrays, particularly multi-dimensional. Some of Dan's questions involve this and some valid creation statements freaked me out.
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
I second Brian on this one!
I agree. Here's the link:
subject: interesting syntax
It's not a secret anymore!