Skip to Content
Real World XML
book

Real World XML

by Steven Holzner
January 2003
Beginner to intermediate content levelBeginner to intermediate
1200 pages
23h 42m
English
Peachpit Press
Content preview from Real World XML

Java Operators

As in JavaScript, operators are an important part of programming in Java. Here's an example of adding two values using the Java + operator:

Listing . ch10_06.java
 
public class ch10_06
{
    public static void main(String[] args)
    {
        int int1 = 130, int2 = 250, sum;

        sum = int1 + int2;

        System.out.println(int1 + " + " + int2 +
            " = " + sum);
    }
}

Here are the results of this code:

%java ch10_06 
130 + 250 = 380

So what operators are available in Java? Table 10-1 contains all of them. Note that nearly all of them are shared by JavaScript as well.

Table 10-1. Java Operators
Operator Operation Performed
++ Increment
-- Decrement
= Assignment
== Equal to
+ Addition
+= Addition assignment
- Subtraction
-= Subtraction assignment
* Multiplication ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Inside XML

Inside XML

Steven Holzner
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0735712867Purchase book