+ 2
/*The problem is you haven't created any object of the class "hello" and you are using it's method in main class. It's a rule of OOPs that if you want to use a method of class in another class then you have to create an object of the class that you want to use. Here his solution to your problem: */ class hello { public void sam(int a,int b) { int sum=a+b; System.out.println("sum="+sum); } } class Demo { public static void main(String args[])throws Exception { hello a = new hello(); a.sam(90,30); } } /* I have just created an object named "a" to use the method sam(). To use method sam() just call it by the line a.same(90,30); If you got any doubt you can ask. if you want to test it just copy this comment and run it with java compiler Hope this will help😄 */
13th Jun 2019, 4:36 AM
Deepak Kumar
Deepak Kumar - avatar
+ 1
or //public void sam(int a,int b) static public void sam(int a,int b) //sam(90,30); hello.sam(90,30);
13th Jun 2019, 7:32 AM
zemiak
- 2
The problem in this is u dont know java😁
13th Jun 2019, 3:54 PM
Gali Somasekhar
Gali Somasekhar - avatar