First line of Java Programming- package help
Alright I am using Netbeans IDE 6.9.1
When I start a new project I get very lil code on the right hand side.
The very first line (of actual code, not the comments) is package javaapplication11;
Now I am watching/reading/listening to some tuts on youtube. The person on youtube is using Eclipse and can just go straight to typing
public class Main{}
I want to be able to just do that. Go straight to typing class so I can follow along with the tuts. But if I take out the package statement it wont let me continue.
Says missing package statement.
Am I just completely overlooking something?
I know this is a really really basic question that may be easy to most of you but like I said Im just learning this stuff.
Any help greatly appreciated it.
Oh and hello to all of you lol.
Re: First line of Java Programming- package help
That line means it's part of a package. You may run into problems if you remove that as it might not recognize stuff that might be in other classes that the tutorial might be using that are in that package.
Re: First line of Java Programming- package help
In any IDE, when you write java class. your first line of code is package, but it need not be necessary. once you started writing your java class and inside that if you are trying to write the code which required some specific package, then you have to declare untill then not required.
for your information java.lang is default package.
Note: if you are writing your java class in any private folder then you have declare the package accordingly.
Thanks
Motilal
Re: First line of Java Programming- package help
package is a kind of folder in which your program is being stored. So Eclipse on your computer has created a 'folder' named "javaapplication11" when you created a new project, while the one in the tutorial video is using the 'default package' which need not be mentioned in the program. Packages create no complexity so don't be scared of them. Just see how these folders are arranged In Eclipse go to Windows>Show View>Package Explorer. In the package explorer window click {your_project} >src>javaapplication11 ... here it is... inside it is your class file. :) packages help avoid name clash of the "Titans"... oopsie... "Classes"
Re: First line of Java Programming- package help
Welcome iNoshift
My advice is to use the same IDE as the tutorial you are following, for the following reasons.
1 Knowing more than one IDE will not kill you
2 Knowing more than one IDE will actually benefit you (versatility as well as a better understanding of java from the 3rd person perspective)
3 Following the tutorial will prove much easier (this is the reason that ultimately led to this post it seems)