Java
  Home arrow Java arrow Page 2 - Java Operators
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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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


    Java Operators - Assignment Operators


    (Page 2 of 4 )

    Variables with no data are just like frosty cold mugs with no soda in them --worthless. Sure, your girlfriend could throw them at you when you forget to take out the garbage or mention how pretty her sister looks. But when mugs and variables were invented, it was because their creator wanted an object that would hold something. In the case of mugs, it's beer, and in the case of variables, it's data. That's where certain kinds of operators come in.

    To fill a variable with data, you use one of the assignment operators, the simplest of which is the = symbol.


    my_iQ = 250;

    The above code assigns the value 250 to my_iq (I didn't want to be boastful, so I lowered the amount). If I later decided what the heck, why not be boastful, I could always do this:


    my_iq = 250;

    my_iq = my_iq + 50;

    This would first assign the value 250 to my_iq, then add 50 to the value of my_iq, leaving it at 300, which is what it truly is (wink wink). A simpler way to write the above code is like this:


    my_iq = 50;

    my_iq += 50;

    If I were drinking the night before, I could also use the subtraction assignment operator to show my true IQ:


    my_iq = 300;

    my_iq -= 250;

    The code above would show that alcohol has reduced my monstrous IQ to a feeble 50.

    If you are working with text or strings, you could do the following:


    class MyName {

    public static void main(String[] args){

    String first_name = “James”;

    String second_name = “Payne”;

    String full_name = first_name + second_name;

    System.out.println(full_name);

      }

    }

    The above sample will print out the text: “James Payne” to your monitor.

    More Java Articles
    More By James Payne


       · thanks for dropping by to read this installment of Java Operators. It covers the...
       · Just like to say thanks for the article - clear, informative and funny at the same...
     

       

    JAVA ARTICLES

    - New Object Initialization in Java
    - 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





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT