Solved

New to Java programming

Posted on 2003-11-01
5
236 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
ID: 9664346
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
ID: 9664350
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
ID: 9669716
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
ID: 9669724
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
ID: 9670059
Thanx ;-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse digits of a number using for loop 5 52
Desingning Refactoring existing code 2 26
JavaFX TableView not displaying correctly 3 55
Eclipse for Java EE development 2 26
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

809 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