Results 1 to 7 of 7

Thread: [RESOLVED] To Import <<Very Newb Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    247

    Resolved [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?

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    247

    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

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  5. #5
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    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.

  6. #6
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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)
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  7. #7
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width