Solved

New to Java programming

Posted on 2003-11-01
5
212 Views
Last Modified: 2010-03-31
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
Comment
Question by:samsungfanatic
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 40 total points
Comment Utility
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
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
Comment Utility
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
 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
Comment Utility
Afterall, jimmack has already answer your question clearly and i think you should accept his comment as answer :p

Good day
-Child-
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
Thanx ;-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now