This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operators" Watch "Operators" New topic
Author

Operators

Albertina Gonzalez
Greenhorn

Joined: Apr 23, 2002
Posts: 11
Hi,
I have a question about this ...
int x =10++11;
I say, that this is a invalid statement, because the operator is applicated over the variable...
What do you know?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Compile it and see - you'll find that this does not compile as the ++ operator has no variable to operate upon.
Corey


SCJP Tipline, etc.
geetha nagarajan
Ranch Hand

Joined: Jul 13, 2001
Posts: 94
if it's written as :
1) int x = 10+ +11;
It works ,the o/p is 21.
2)int x = 10 + +11;
It works ,the o/p is 21.

Is the positioning of space so important,pl.help clarify.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by geetha nagarajan:
if it's written as :
1) int x = 10+ +11;
It works ,the o/p is 21.
2)int x = 10 + +11;
It works ,the o/p is 21.

Is the positioning of space so important,pl.help clarify.

In this case, the space makes little difference as to where it is. The only thing that matters is that there is a space between the '+' signs. If they're together, they represent the increment operator in Java. If they're separate, they represent the addition operator.
Corey
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
This may be helpful JLS 3.2

The longest possible translation is used at each step, even if the result does not ultimately make a correct program while another lexical translation would. Thus the input characters a--b are tokenized (�3.5) as a, --, b, which is not part of any grammatically correct program, even though the tokenization a, -, -, b could be part of a grammatically correct program.


SCJP2. Please Indent your code using UBB Code
 
Consider Paul's rocket mass heater.
 
subject: Operators
 
Similar Threads
Cant use object from another class
Posting to bump up my count...
Text box value is not being completely filled with request attribute
WA #1.....word association
The x900 effect ?