Java
  Home arrow Java arrow Page 4 - Java Operators
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Java Operators
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2007-10-22

    Table of Contents:
  • Java Operators
  • Assignment Operators
  • Doing More Math with Assignment Operators
  • Forming a Relationship with Operators

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Java Operators - Forming a Relationship with Operators


    (Page 4 of 4 )

    Admit it, back in the old days when real people answered the phone, you often thought...I bet this operator is hot. Maybe you even flirted a little. Perhaps you even went as far as to try to make a date with the operator, and when she said she didn't know you, you took that as a sign that you should call her back every hour until she did know you. Nice try; you'll be glad to hear then that working with relational operators is quite different from trying to get a date from an operator.

    Relational operators compare data to one another. Below is a hot list of relational operators and what they do:


    Operator Symbol

    What It Does

    “==”

    Equal To

    !=

    Not Equal To

    >

    Is Greater Than

    <

    Is Less Than

    >=

    Greater Than or Equal To

    <=

    Less Than or Equal To

    Relational operators will come in handy when we take a look at Conditionals and Loops. For now, here is a sampling of what that relationals look like in code:


    class FlexOff {


    public static void man(String[] args) {

    int my_muscles = 10;

    int your_muscles = 1;


    if(my_muscles > your_muscles) System.out.println(“My muscles are larger than yours!”);


    if(my_muscles < your_muscles) System.out.println(You must be taking steroids.”);


      }

     }

    In the above code, we have to value: my_muscles and your_muscles. Each is assigned a numeric value from 1 to 10, with 10 being the greatest. We then have an If-statement (we will go over these in another tutorial) that states if my_muscles are greater than your_muscles, do this. In the above sample,  my_muscles are indeed greater than your_muscles (by a factor of ten no less; I'm practically Hercules) and so the program will print out:

      My muscles are larger than yours!

    Had your muscles been bigger than mine, two things would have occurred: 1) Hell would have frozen over and 2) the following text would be written to the screen:

      You must be taking steroids.

    Now let's imagine that you were stronger than me. When I had you called up for review by the Steroid Usage is a No No Board, they would ask you, Yes or No, True or False...have you used steroids?

    And with that little segue, it's time to introduce you to the Boolean Logical Operators.

    Unfortunately for you however, we have run out of time for this tutorial. But never fear; in our next tutorial we will cover the rest of the operators and delve into Statements.

    Until then however, feel free to study this table of our remaining Operators:


    Operator Symbol

    What it Does

    &

    And (Logical)

    |

    Or (Logical)

    ^

    XOR (exclusive OR)

    ||

    Or (short circuit)

    &&

    And (short circuit)

    !

    Not (logical unary)

    &=

    AND assignment

    |=

    OR assignment

    ^=

    XOR assignment

    “==”

    Equals

    !=

    Not Equal To

    ?:

    If-then-Else (ternary)

    Till next time (plays Batman theme song). POW! BLAM! BIFF! BOP!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · thanks for dropping by to read this installment of Java Operators. It covers the...
     

       

    JAVA ARTICLES

    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup

    BlackBerry VTS




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway