Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Squaring of two number in Static class

                         

In this section we will learn how to use static method and how can display multiplication of two any number. The static method use no instance variables of any object of the class they are defined in example. 

Description of program
Here this program calculate the any two number . First of all, we have to define class named "StaticSquare" . To square a static method  are define main class and passing the two parameter of integer type values. Then we have to define the two integer type values in the class method. We are going to create object for calling the two number by using this method "staticSquare.main(a,b)" and after that "staticSquare.square1()" is return the integer type values for x and "staticSquare.square2()" is return the integer type values for y value. Now we are going to used parseInt method for converting the argument value into the string values. So output will be display on the screen by using the System.out.println() method in the command prompt.

Here is the code of this program

import java.io.*;

class StaticSquare {
  public static int x;
  public static int y;
  public static void main(int x1, int y1){
   x=x1;
   y=y1;
   }
    public int square1(){
    return (x*x);
    }
    public int square2(){
    return (y*y);
    }
    public static void main(String args[]){
      try{
        StaticSquare staticSquare=new StaticSquare();
        BufferedReader sq=new BufferedReader (new InputStreamReader(System.in));
        System.out.println("Enter two number");
        int a=Integer.parseInt(sq.readLine());
        int b=Integer.parseInt(sq.readLine());
        staticSquare.main(a,b);
        System.out.println("value1 is=" + a);
        System.out.println("value2 is="+ b);  
        int sq1=staticSquare.square1();
        int sq2=staticSquare.square2();    
        System.out.println("square of value1 is= " + sq1);
        System.out.println("square of value2 is= "+ sq2);  
        }
        catch(Exception e){}
    }
}

Download this example

                         

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 
Latest Searches:
Developing JSP files
Java show Vowels in th
password
<c:forEach>
count row in resultset
how to input 2 xml fil
call ejb j2ee5
Parsing the data on th
ComboBox
add delete javascrip
jQuery To Hide the Div
Configure jstl in web.
Display Data from Data
Photoshop Photo Effect
public void actionPerf
File InputStream
Bean Tag (Data Tag) Ex
xml to telnet
Reading File into Byte
Applet event button
html textarea
persistent cookie
project of online bank
arraylist in struts
unix commands in shell
bank application
Hash Function in Java
java nodequeue tutoria
Java code for media pl
sum
secure
VNCj (Java VNC S
code fro finding index
Retrieving Data From d
user validation
Treemap using gwt tree
ASP Form Processing Ch
standered jstl jar to
iterator
PHP User Authenticatio
disable minimize butto
panelgrid with its ren
PHP Introduction to PH
session get data fro
Create table and inser
update data from mysql
how to pass same varia
xml stream
paypal
comparing the elements
oracle.jdbc.driver.Dat
PHP Database Related M
lookupdispatch
code to store a string
add two integers in ja
example of JFileChoos
how to declare an arra
struts layout tags
web
introduction to struts
how to export zeroes t
drow arc
example program of poi
draw Polyline
Generic Eclipse Modeli
convert string array t
excel from java
save image to file
Get Image
netbeanscode
java buffer
login logout struts
spring hibernate ehcac
String to array in jav
access element of html
tabindex
session
jsf tab
goto
oXygen
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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 | 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.