Monday, 5 October 2015

Static method example in java

/**
 *
 */

/**
 *
 *
 */
public class Staticmethords {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
      int m = Staticm.sum(10,20);
      System.out.println("The value is " +m);
}
}



public class Staticm {
static int l;
static int sum(int i,int k){
//return (k+i);
l=i+k;
return (l);
}
}

Output:-
The value is 30

No comments:

Post a Comment