Jun 28 2009

Parameter passing

Category: Javaadmin @ 7:43 am

  • Without Parameter passing

class calculator {
 
public static void main (String[] args)
 
{
int x = 3;
int y = 5;
 
int add = x + y;
System.out.println(add);
int mul = x * y;
System.out.println(mul);
}
}
class calculator {
public static void main (String[] args)
 
{
System.out.println(11+12);
System.out.println(30+50);
System.out.println(2+3);
System.out.println(60+2);
System.out.println(11+35);
System.out.println(37+50);
System.out.println(52+3);
System.out.println(20+2);
}
}

  • Parameter passing

class calculator {
 
public static void main (String[] args)
 
{
int no1 , no2 ;
no1 = 3;
no2 = 5;	
 
addition (no1,no2);
multiplication (no1,no2);
 
}
 
public static int addition(int x,int y)
 
{
int add = x + y;
System.out.println(add);
}
 
public static int multiplication(int x,int y)
 
{
int mul = x * y;
System.out.println(mul);
}
 
}
class calculator {
public static void main (String[] args)
 
{
add(11,12);
add(30,50);
add(2,3);
add(60,2);
add(11,35);
add(37,50);
add(52,3);
add(20,2);
 
}
 
static void add(int x,int y){
System.out.println(x+y);
}
}

Tags: ,

6 Responses to “Parameter passing”

  1. MishaPowerauto says:

    Just wanted to say HI. I found your blog a few days ago on Technorati and have been reading it over the past few days.
    tharinduchandima.co.cc – cool!!!!

  2. LenaShopogolik says:

    Interesting site. Shall read as subscription, rss.

  3. Vivalkakira says:

    Fantastic! :)

  4. blondinkaya says:

    thanks for the great information…

  5. yapapanyatt says:

    i found you by link from the Directory Listing Script from Ash.. Nice to read your blog ^.^

  6. Molichaiche says:

    The best information i have found exactly here. Keep going Thank you

Leave a Reply