class farhan
{
void b()
{
System.out.println("farhan se milo ");
}
}
class Muzammil extends farhan
{
public static void main(String...a)
{
farhan f=new farhan();
f.b();
System.out.println("program kyo bnate ho");
}}
program not run on my computer
Page 1 of 17 Replies - 114 Views - Last Post: 03 October 2012 - 07:53 PM
Replies To: program not run on my computer
#2
Re: program not run on my computer
Posted 03 October 2012 - 01:38 PM
You need to have the main method in a public class.
#3
Re: program not run on my computer
Posted 03 October 2012 - 07:17 PM
which match the name of the .java file
#4
Re: program not run on my computer
Posted 03 October 2012 - 07:22 PM
In short, add public to your class name definition, and put it in a file named with your class name and with an extension of .java.
#5
Re: program not run on my computer
Posted 03 October 2012 - 07:33 PM
Actually does not really need to be public, can be protected
Just move the main() class to farhan and it will work
Just move the main() class to farhan and it will work
#6
Re: program not run on my computer
Posted 03 October 2012 - 07:39 PM
That's new to me, thanks! I'll probably read up on it once I reach classes on the Java Tutorials.
#7
Re: program not run on my computer
Posted 03 October 2012 - 07:47 PM
fromTheSprawl examples that are showed in this forum are always extreme and do not reflect what you would see in real life.
In real life nobody would bother extend a class which have only a few lines (but for educational purposes) so in real life clas farghan would have a few dozens lines
so nobody would extend it in the same .java file
so the showed case would never happen in real life
In real life nobody would bother extend a class which have only a few lines (but for educational purposes) so in real life clas farghan would have a few dozens lines
so nobody would extend it in the same .java file
so the showed case would never happen in real life
#8
Re: program not run on my computer
Posted 03 October 2012 - 07:53 PM
Well, as much as possible I would like to know as much as how stuff works in Java, like this one, I think it is simple but I didn't know that it could still run without the public class. I might have misguided him if not for your correction.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|