|
-
Mar 3rd, 2006, 06:50 PM
#1
Thread Starter
Addicted Member
[RESOLVED] To Import <<Very Newb Question
I am learning Java currently, and I have learned the basic System.out.println functions, variables, and string/character stuff. Like here is some example stuff I work on:
Code:
class Example1 {
public static void main(String Args[]) {
System.out.println("This is the output from Example1");
}
}
Code:
class Trial1 {
public static void main(String Args[]) {
System.out.println("This is my test");
System.out.println("I hope it works");
}
}
Code:
class DisplayFloat {
public static void main(String args[]) {
float price;
price = 45.35f;
System.out.print("The Price is ");
System.out.println(price);
}
}
Code:
public class OutputVariables {
public static void main(String args[]) {
char ch = 'X';
short s = 456;
double d = 123.009;
System.out.println("Ch is " + ch);
System.out.println("S is " + s);
System.out.println("D is " + d);
}
}
--Those are some examples and I also know printing strings and whatnot. But I was wondering a simple question. When you use the:
import _______ function, does that automatically call it or do you have to have it in the directory with the program?
-
Mar 3rd, 2006, 07:22 PM
#2
Re: To Import <<Very Newb Question
You must have it in the class-path property in windows "environment variables" table
another thing
import is not a function
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Mar 3rd, 2006, 09:53 PM
#3
Thread Starter
Addicted Member
Re: To Import <<Very Newb Question
I do not get anything you just said. Can you give me an example on how to import and what not. I really want to learn more Java because I am getting into this now
-
Mar 4th, 2006, 03:13 AM
#4
Re: To Import <<Very Newb Question
e.g:
import java.awt.Graphics;
import myPackage.*;
import myPackage2.MyClass;
but myPackage and myPackage2 must be:
1- in the same path "folder, directory" of the class file I'm importing them in
2- the paths "directories" must be defined within the "classpath" in windows
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Mar 4th, 2006, 03:15 AM
#5
Lively Member
Re: To Import <<Very Newb Question
If you have installed a jdk,then you shouldnt worry about importing and the location where the files are in.So if you want to import something for io(input and output),you would just use
import java.io.*;
(Here io is the subdirectory under the main java package).Hope this helped.
-
Mar 4th, 2006, 03:18 AM
#6
Re: To Import <<Very Newb Question
 Originally Posted by sid_19840
If you have installed a jdk,then you shouldnt worry about importing and the location where the files are in.So if you want to import something for io(input and output),you would just use
import java.io.*;
(Here io is the subdirectory under the main java package).Hope this helped.
Not really
unless you only use java main packages (only students does)
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Mar 4th, 2006, 07:06 AM
#7
Lively Member
Re: To Import <<Very Newb Question
 Originally Posted by ComputerJy
Not really
unless you only use java main packages (only students does)
He said that he is a newb,so I assume that he's trying to import the existing java packages.However if he is trying to make his own packages then he should have easily understood your earlier post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|