Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: need to make basic class and implementation class (base class without void main)

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts

    Default need to make basic class and implementation class (base class without void main)

    The whole question:
    create a method with purpose
    For every method you create, you need to write codes in the implementation class with an object calling the method and output the result. The following are specific:

    Part 1: create a

    ` public method called switch_number()`

    You can create it in your base class or derived class. (please follow)

    ` public void switch_number(int i, int j)`

    ----this is how you switch number

    int t;
    int w = 2;
    int w2 = 4;
    int t = w;
    int w2 = t;
    int w = w2;

    this is syntax for switching numbers, I just don't know how to make a method out of this in a base class. Now Base class can't have public static void main(String[] args) {


    Part 2: Create a

    ` public method called return_big()`

    . This function will take 2 numbers and compare them, then return the bigger number back to caller
    this is a if statement, I could give you guys the syntax for this, but i'm pretty sure most of you know how to do this

    Part 3: Create a

    `public method called sort_3()`

    . This function will take 3 integers and use switch and compare to sort them out and print out 3 numbers from the smallest to the greatest.
    this is also an if statement, I could give you guys syntax for this, but again i'm sure you guys know this

    Also, I need to use joptionpane to get input and display output. Here is a sample of joption pane

    import javax.swing.JOptionPane;

    String z = JOptionPane.showInputDialog("Enter first integer:"); //asks user for input integer and stores it in string z
    switch1= Integer.parseInt(z);//converts number in z and stores it in int w
    String z2 = JOptionPane.showInputDialog("Enter second integer"); //asks user for second integer and stores it in z2
    switch2 = Integer.parseInt(z2); //stores z2 number in int w2

    This prompts user to enter integers. Please help me with the syntax for the basic class stuff, that is what I don't understand, and how to implement it into the implementation class just by calling on the object and method. Each parts can be done in the same base class, no need to make a new project for each part. Sorry if this is long, but I tried to be as specific as possible. Please help

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,637 Times in 2,587 Posts

    Default Re: need to make basic class and implementation class (base class without void main)

    p me with the syntax for the basic class stuff
    Check out the tutorial:
    What Is a Class? (The Java™ Tutorials > Learning the Java Language > Object-Oriented Programming Concepts)
    Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 03:21 AM
  2. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM
  3. [SOLVED] How to make a class be static if it's the main class.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: January 10th, 2012, 05:14 AM
  4. How do I call a class in a main class
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 26th, 2011, 03:11 AM
  5. Calling a void method into a static void main within same class
    By sketch_flygirl in forum Object Oriented Programming
    Replies: 3
    Last Post: November 15th, 2009, 05:24 PM

Tags for this Thread