+ 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đ
*/
+ 1
or
//public void sam(int a,int b)
static public void sam(int a,int b)
//sam(90,30);
hello.sam(90,30);
- 2
The problem in this is u dont know javađ



