File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes increment operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "increment operators" Watch "increment operators" New topic
Author

increment operators

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100


I fail to understand the 2 + signs before k in 1.
Shilpi M Ag
Ranch Hand

Joined: May 07, 2004
Posts: 40
You can very well remove one of the +.. It is there to confuse us.. and simply means that k is positive.

You can change it to the following to see the difference
black night
Greenhorn

Joined: Jun 18, 2004
Posts: 5
hi angeela
i am totally agree with silpi , its only to cofuse , + + or even hundred + means the same one + . Here first + for addition and second + for sign notation


code:

public class TestClass
{
public static void main (String args[ ] )
{
int k = 1;
int i = ++k + k++ + + k ;
System.out.print(i+ " "+ k) ;
}
}
/*
++k = 1 + 1 =2
k++ = 2+1=3
+k = +3


i = ++k(2) + k++(2) + +k(3);
i = 2 + 2 + 3 = 7
*/



The solution might be confusing.If is there any mistake then please tell me . cia
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: increment operators