Solved

New to Java programming

Posted on 2003-11-01
5
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

696 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