Overclock.net banner

1 - 8 of 8 Posts

·
Registered
Joined
·
519 Posts
Discussion Starter #1
What do the following mean and why are they there:

Import java.awt.graphics (whats with the dots?)

java.lang.Object (is this extend only?)

public static void main(String[] args)(what the heck is this????)

;

Also is there a basic way to use other classes? thank you!!!
 

·
Premium Member
Joined
·
13,844 Posts
You use dots in the imports so that you can import classes, like the Graphics class you want to import in the first statement. And Import should be spelled import. Java is case-sensitive.

public static void main(String [] args) lets you "run" a class to create output. So if I wanted to print "Hello, world!" to the screen, I would need a main() method so that I could output it.
 

·
Registered
Joined
·
519 Posts
Discussion Starter #3
what would happen if public static..etc wasn't there?

when you said main() inside the parenthesis would be sting [] args?

also are you explaining import or what the dots are for?

for the brackets{1
{2
2}
1}
is 2 the end of the program or can you place other programs inside the 1 brackets?
 

·
Premium Member
Joined
·
13,844 Posts
If I wanted to put static methods in my class, I would put them after the closing 2} brace and before the 1} brace if I had a main() method.

So it would go like this:
public class HelloWorld
{
public static void main(String [] args)
{
//stuff in the main method goes here, like System.out.println("Hello, world!");
}

public static void someMethod()
{
//doStuff;
}
}
 

·
Premium Member
Joined
·
13,844 Posts
C++ and Java are close syntactically, but they differ slightly...Do you want me to explain what the differences are or is that good enough?
 

·
Premium Member
Joined
·
3,590 Posts
Don't worry really about what (sting [] args) means, once you move into more advance stuff and into Object Oriented Programing you'll understand.

Quote:


Originally Posted by Modex

also are you explaining import or what the dots are for?

Both, the dots are used for importing. Are if you wanted everything say in the utilities class then its like java.util.*
Or if I only wanted the Scanner class out of Utilities: java.util.Scanner
 
1 - 8 of 8 Posts
Top