[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?
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
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
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
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.
Re: To Import <<Very Newb Question
Quote:
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)
Re: To Import <<Very Newb Question
Quote:
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.