Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
The Unary Operators 
 

In this example we will see how we can make use of the unary operator. In java we have been provided the unary operators so we should know how to make use of those operators.

 

The Unary Operators in Java

                         

In this example we will see how we can make use of the unary operator. In java we have been provided the unary operators so we should know how to make use of those operators.  Unary operators are:

++expr, --expr, +expr, -expr, ~, !

Description of program:

In this section we will know how to make use of the unary  operators in java. First all of, we have to define a class "UnaryOperation" . Inside this class we have defined one class variable. We are making one overloaded main method which takes one integer type argument. Define one method operate() of type int where we are going to use the various unary operators.  At last inside the main method call the method operate() so that the result can be displayed to the user. The output will be displayed  on the screen by using the println() method of the System class. 

Here is the code of this program

class UnaryOperation {
    public static int i=0;
    public static void main(int i){
     i=i;
    }
    public static int operate(){
          int i = +1
          System.out.println(i);
          i--;  
          System.out.println(i);
          i++; 
          System.out.println(i);
          i = ++i; 
          System.out.println(i);
          boolean success = false;
          System.out.println(!success)
          System.out.println(success)
      return 0;
      }
      public static void main(String args[])
      {
      UnaryOperation uo= new UnaryOperation();  
      int i=uo.operate();
    }
  }

Download this example

                         

» View all related tutorials
Related Tags: c convert io help this ai program to learn ram unit ear e il it section not in no converting

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.