Results 1 to 6 of 6
Thread: New to Java, need some help
- 09-09-2010, 12:42 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 2
- Rep Power
- 0
New to Java, need some help
Hio. I'm new to Java, and OOP. I am using NetBeans IDE.
I've been googling around, but I can't seem to find a specific answer to what I am looking for. What exactly IS a package, and a library?
Also, I've been looking at some tutorials and things, and I want to know what is mandatory and what is just popular trend. Do all .java files need a main class, and do all projects need a Main.java file?
Any help would be appreciated. :)
- 09-09-2010, 12:45 AM #2
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
Go through this link it will be helpful to you get some knowledge.
Learn Java online with Java Beginner Tutorial
- 09-09-2010, 01:05 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 2
- Rep Power
- 0
So everything needs a class, and inside that class a function called main? I was testing some things.
That worked, but it didn't work when I removed the public class main (and it's curly brace) and it did not work when I changed the name of the main function. Is this correct?Java Code:public class Main { public static void main(String[] args) { System.out.println("Hello, world!"); } }
- 09-09-2010, 01:39 AM #4
The main() method your talking about is a requirement from the Java program as THE method it will call when starting the execution of your program. Any class you start execution of with the java command must have that method.
There does NOT have to be a class named Main. The java program doesn't look for or require a class with that name. That name is a convention used by IDEs
- 09-09-2010, 04:43 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-11-2010, 01:36 AM #6
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Every "library" needs an access point that is a main(). It needs to be static because static requires no instance declaration of the class, it needs to be public so it is accessible to all programs it needs curly braces because everything inside them defines a function.


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks