+ 1

can anyone tell me how to send some values to othet method...pls help me..i need in my project...

method problem

30th Nov 2017, 11:28 AM
Sauvik Saha
Sauvik Saha - avatar
3 Answers
+ 23
1) when u want to make method without object , then u can use static keyword in front of method example ::: static void method1 (){} //u can use String , if it returns string value as output , if it does not return any value then u can use void example ::: public class program{ public static void main (String hello []){ printsauvik (); } static void printsauvik (){ System.out.print ("sauvik");} } 2)public class program { public static void main (String args []){ program p1=new program (); String a="sauvik saha"; p1.method2(a ); } public void method2 (String b){System.out.println(b);} } //might more ways , but i'm a very true beginner ... know only this much
30th Nov 2017, 12:26 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
The method should take arguments and arguments can be passed when calling the method. public static void method(string arg1, int arg2) { // do something } public void function() { string foo = "bar"; int num = 42; this.method(foo,num); }
30th Nov 2017, 11:51 AM
Adam Schmitt
Adam Schmitt - avatar
+ 1
thanku very much
30th Nov 2017, 1:01 PM
Sauvik Saha
Sauvik Saha - avatar