1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Any Java developers out there?

Discussion in 'BBS Hangout' started by GladiatoRowdy, Sep 27, 2007.

  1. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    I am taking a Java class and so far, my instructor has been spectacularly less than helpful when it comes to the assignments we need to complete and turn in. I have a couple of questions about the program I am writing and was hoping for a few minutes of tutor time.
     
  2. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
    Post your code and questions here, maybe I can help.
     
  3. SLrocket

    SLrocket Contributing Member

    Joined:
    Oct 9, 2006
    Messages:
    1,041
    Likes Received:
    0
    im taking compsci I honors in school lol
     
  4. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    I am taking my first JAVA class as well at UH. The instructor cant teach worth crap! Why is it so hard to teach java?
     
  5. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
    It's not. I taught it for 2 1/2 years. What's your question?
     
  6. DarkHorse

    DarkHorse Member

    Joined:
    Oct 9, 1999
    Messages:
    6,756
    Likes Received:
    1,303
  7. coolweather

    coolweather Contributing Member

    Joined:
    Jul 20, 2005
    Messages:
    2,087
    Likes Received:
    58
    I can help you to create a Hello World program. :)
     
  8. wreck

    wreck Member

    Joined:
    Jul 18, 2006
    Messages:
    3,551
    Likes Received:
    47
    Im having a lot of trouble with c++. its an online course. should i be worried. :(
     
  9. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218

    can you have more than one class in one program? And how would that work? What do you save the file as?
     
  10. teknokid

    teknokid Member

    Joined:
    Aug 22, 2002
    Messages:
    950
    Likes Received:
    34
    INHIBERNATE NOWWWWWWWWWWWWW
     
  11. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    POST THE DAMN CODE!!!


    Using the code tags please.
     
  12. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
    If what you meant by program is a single file, then yes. You declare your initial class, the one with the main function in it, as a public class. then whatever utility classes you have you don't put the public key word in front of them. And the file need to have the same name as the your public class.
     
  13. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    awesome, makes sense

    so it would be liek

    ------------
    public class Rockets
    {

    public static void main(String args [])
    {

    System.out.println("I love the rockets");
    Tmac.shots();
    }

    }

    class Tmac
    {
    shots()
    {System.out.println("i took 30 shots");
    }
    }
     
  14. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
    well, kinda, but since your shots method is not static, you have to initiate the Tmac class first.

    public class Rockets
    {

    public static void main(String args [])
    {

    System.out.println("I love the rockets");
    Tmac tracy = new Tmac();
    tracy.shots();
    }

    }

    class Tmac
    {
    public void shots()
    {System.out.println("i took 30 shots");
    }
    }
     
  15. AMS

    AMS Member

    Joined:
    Oct 8, 2003
    Messages:
    9,646
    Likes Received:
    218
    awesome, and the professor took 3 weeks to confuse teh crap out of me...
     
  16. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    I am writing a histogram class that is supposed to grab data from an instructor provided class called histogramData.class. Unfortunately, even though it is in the directory specified in my classpath, NetBeans keeps reporting that my reference to histogramData is bad.
     
  17. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    Do I need to import it like I import other Java objects? If so, do I specify the class file (histogramData.class) or is that unnecessary?
     
  18. Jimes

    Jimes Member

    Joined:
    Mar 28, 2006
    Messages:
    868
    Likes Received:
    27
    Did your instructor put that class in a package? Cause then you would have to import it in your file after setting your classpath to the directory above the package.

    For example:
    c:\Rockets\Data\histogramData.class with histogramData in the Data package.

    You could have your file in Rockets and then import Data.*.
     
  19. GladiatoRowdy

    GladiatoRowdy Member

    Joined:
    Oct 15, 2002
    Messages:
    16,596
    Likes Received:
    496
    I have the histogramData.class file in the c:\Program Files\Java directory, which is in my classpath variable. I don't know what to do from there.
     
  20. Jimes

    Jimes Member

    Joined:
    Mar 28, 2006
    Messages:
    868
    Likes Received:
    27
    Did your instructor give you any information about how to use that file?
    He must have said what class is in it (probably histogramData) and how to use that class. You should only need to import if it's in a package.

    What environment are you using, Eclipse?
     

Share This Page