Java
  Home arrow Java arrow Page 2 - Java Operators
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
JAVA

Java Operators
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 12
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek