| Author |
Message |
wtd
|
Posted: Fri Apr 22, 2005 9:57 pm Post subject: (No subject) |
|
|
Yes, anything printed with System.out goes to the standard output, which is the terminal window, by default.
Can you please show me the exact program you're compiling? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Vertico
|
Posted: Fri Apr 22, 2005 10:21 pm Post subject: (No subject) |
|
|
| code: |
import java.io.*;
import java.lang.*;
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("what is up people");
}
}
|
its the exact program u wrote out before. except i changed the print |
|
|
|
|
 |
wtd
|
Posted: Fri Apr 22, 2005 10:34 pm Post subject: (No subject) |
|
|
After you made a change to the program, did you recompile it, or just run it again?
When you make a change to a Java program you must recompile it. You see, the source code lives in (in this case) HelloWorld.java. But when we compile with:
| code: | javac HelloWorld.java |
The program is converted to a format the Java virtual machine can use, and this is placed in the file HelloWorld.class. It's this file which:
Is concerned with. If you don't recompile, that file is unchanged, and any changes to HelloWorld.java won't be seen in the results. |
|
|
|
|
 |
Vertico
|
Posted: Sat Apr 23, 2005 8:14 am Post subject: (No subject) |
|
|
do u know of a website that can help me through this? like the most slowest newbiest yet effective site to help me learn how to run files?
cuz i keep trying what ur saying and i keep getting nothing back but what i type. |
|
|
|
|
 |
Hikaru79
|
Posted: Sun Apr 24, 2005 1:45 pm Post subject: (No subject) |
|
|
| Also, you don't need either of the import statements you used at the top. You don't need java.io.* because you're not using it anywhere in your program, and you don't need java.lang.* because its imported by default -- you don't need to worry about that. |
|
|
|
|
 |
wtd
|
Posted: Sun Apr 24, 2005 4:12 pm Post subject: (No subject) |
|
|
Hikaru79 wrote: Also, you don't need either of the import statements you used at the top. You don't need java.io.* because you're not using it anywhere in your program
It never hurts to have either of these import statements. |
|
|
|
|
 |
1of42
|
Posted: Sun Apr 24, 2005 9:33 pm Post subject: (No subject) |
|
|
| But isn't it extraneous and unnecessary? |
|
|
|
|
 |
rizzix
|
Posted: Sun Apr 24, 2005 9:48 pm Post subject: (No subject) |
|
|
| one can argue.. it self-documents the code.. so yea... well refering to the java.lang package i.e.. the java.io is unnecessary. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Hikaru79
|
Posted: Wed Apr 27, 2005 12:00 am Post subject: (No subject) |
|
|
wtd wrote: Hikaru79 wrote: Also, you don't need either of the import statements you used at the top. You don't need java.io.* because you're not using it anywhere in your program
It never hurts to have either of these import statements.
Really? It doesn't hurt to import packages you don't use at all? All this time I've been doing stuff like | Java: | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.FileNotFoundException;
|
if those would be the only classes I was using in a particular class. I figured I was getting at least a tiny bit of a boost here for only importing exactly what I needed as opposed to . Have I been misinformed this whole time? Or is there some sort of benefit to my stinginess, however small it may be? Or is the compiler smart enough only to load the bare neccesities? |
|
|
|
|
 |
rizzix
|
Posted: Wed Apr 27, 2005 12:16 am Post subject: (No subject) |
|
|
no this is a compile time issue.. not a runtime issue.. the compiler will optimise ur code importing only what you need.. actually imports are all syntatic sugar.. the bytecode uses the full form internally.
but yea.. ur stingyness can reduce compile time.. but not necessarily improve runtime speed... on the other hand it can be seen as self-documentation  |
|
|
|
|
 |
Hikaru79
|
Posted: Wed Apr 27, 2005 12:40 am Post subject: (No subject) |
|
|
rizzix wrote: no this is a compile time issue.. not a runtime issue.. the compiler will optimise ur code importing only what you need.. actually imports are all syntatic sugar.. the bytecode uses the full form internally.
but yea.. ur stingyness can reduce compile time.. but not necessarily improve runtime speed... on the other hand it can be seen as self-documentation 
*phew* At least I have *some* justification Thanks, rizzix!  |
|
|
|
|
 |
rizzix
|
Posted: Wed Apr 27, 2005 2:13 pm Post subject: (No subject) |
|
|
| yes but there is no point in trying to import stuff you dont use.. its very bad practise... dont do it. |
|
|
|
|
 |
wtd
|
Posted: Wed Apr 27, 2005 3:53 pm Post subject: (No subject) |
|
|
| Don't micro-optimize. If you want several classes from "java.io", import "java.io.*". You could spend lots of valuable time individually importing each class you use, but at the end you'd have done nothing the compiler/VM couldn't do in a fraction of a second. |
|
|
|
|
 |
rizzix
|
Posted: Wed Apr 27, 2005 4:08 pm Post subject: (No subject) |
|
|
depends... if you are using a tool like eclipse... they can automaticaly organise and fold ur import statements.. and by organising i mean expanding it completly and grouping/sorting them in a perticular order..
it actually makes, looking up classes used in that class or file, a breeze.. and bsides cuz of the folding, it dosen't really come in way your while coding..
as for the time "wasted" well, actually none of it is actually wasted.. its all done automatically. |
|
|
|
|
 |
wtd
|
Posted: Wed Apr 27, 2005 4:37 pm Post subject: (No subject) |
|
|
| Perhaps, but I mean, don't spend time typing out each class name you're importing if a "import javax.swing.*;" or such will do the trick. |
|
|
|
|
 |
|