[Solved] Java Class and Object


Actually from the example that you provided I can see that you don’t understand concept of object programming and even concept of functions. So please, start from begining.

And if you want to print carry variable in method user() then you must change this method like this:

void user(int a)
{
    System.out.print(a);
}

and then in main program you will do something like this:

ob2.user(some_int_number);

Also, in java, first letter of class names is capital leter. So class names would be Defined and UserDefined. This is just a good practice.

But yeah, start with basics

solved Java Class and Object