Basic query for method access | Selenium Forum
M
Posted on 14/10/2015
public class login {
private String name;
public void loginUser()
{
System.out.println("User Logging in");
}

public static void main(String[] args)
{
Y bb= new Y();
bb.function();
}
}
class Y
{
void function()
{
System.out.println("back");
}
}



question:

In above program , I created object of class Y through reference bb (Y bb= new Y();) inside main method.
I can access bb.function (); inside main method but why I can't access same inside Class Y.

Please explain the logic.

M
Replied on 15/10/2015

hi,

where in the y class are you trying to access the function()?

if you want to access the function() in y class make a new function1() and execute inside of it.