aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what's the meaning of Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "what Watch "what New topic
Author

what's the meaning of " a[j]++?, thanks

Tu Ran
Ranch Hand

Joined: Feb 09, 2002
Posts: 30
class A {
static void method(int [] a){
int j=1;
a[j]++; //I can't understand this sentence?
}
public static void main(String args[]) {
int [] b=new int[5];
method(b);
System.out.println(b[1]);
}
}


Enjoy java,enjoy life
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
a[j]++ basically increments the value of the j-th element in array a.
Here, we create a new int array of length 5. Then we pass the array to method(). Within method(), we increment its 1st element from 0 to 1 and then finally in main() we print that first element which is now 1.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Tu Ran
Ranch Hand

Joined: Feb 09, 2002
Posts: 30
Thanks my friends--Valentin Crettaz
I see~~
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: what's the meaning of " a[j]++?, thanks
 
Similar Threads
Resolving most specific method
refs to static variables
Need help with triangle drawing applet
insertion sort
Why the result of printing out the not-letter chars to console is different from to applets