[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

New to Java programming

Hi,

I am a new java programmer, i would like to ask the following questions:

1. Say if i wanted to use x.class for some of its methods, how do i let my program "know" that i want to use methods from x.class?

2. Could anyone recommend a good Java IDE?

I would greatly appreciate any help on the above. Thanks.
Samsungfanatic.
0
samsungfanatic
Asked:
samsungfanatic
  • 3
  • 2
1 Solution
 
jimmackCommented:
If you have a class called MyClass, you create an "instance" of it (an object) like this:

MyClass myObject = new MyClass();

If the MyClass has a method called "getName()", you tell the object you created to get the name like this:

String theName = myObject.getName();


The class would look like this:

public class MyClass
{
    private String name;

    public MyClass()
    {
        name = "example";
    }

    public String getName()
    {
        return (name);
    }
}

Java IDE's.  Try:

http://www.netbeans.org

http://www.eclipse.org

Good luck ;-)
0
 
jimmackCommented:
Next level of complexity ;-)

Classes are usually created inside "packages".  A package is a logical collection of related classes.  eg. The package java.awt contains all the main abstract windowing toolkit classes like Frames, Windows, Buttons etc.

If you want your class to be able to access a Button, you "import" the class into your .java file:

import java.awt.Button;

public class MyClass2
{
    private Button myButton;
    .
    .
}
0
 
InNoCenT_Ch1ldCommented:
For your IDE question:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20777711.html

however, i suggest that you use notepad since you are new to Java, this will help you to learn this language.. personally, i've only try JBuilder and i find it quite good, but i'm still prefer to write in notepad ;p

-Child-
0
 
InNoCenT_Ch1ldCommented:
Afterall, jimmack has already answer your question clearly and i think you should accept his comment as answer :p

Good day
-Child-
0
 
jimmackCommented:
Thanx ;-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now