Cant call simple method from main method

hi guys, this maybe a stupid question, im a newbie to java programming. Im trying to call the method calculateArea in main method and its not working.
Any ideas?
Thanks.
package project1;
public class makePurchase {
    public int calculateArea(int width, int height){
            int myArea = width * height;
            return myArea;
    public static void main(String[] args){
        int vTestResult = calculateArea(1,3);
        System.out.println("The total is:" +vTestResult);
}

jverd wrote:
mishmash wrote:
Is there a easy way of determining if the method should be static? maybe only if your using a math class and not using the method in any other class?Static means associated with the class as a whole, not with any particular instance. If your method doesn't use or set any state that is part of individual instances, it may be a candidate to be static. Another difference is that static methods cannot be overridden. That is, you can't defer until runtime which class' implementation of a static method to call.
public class Person {
private static int numPersonsCreated;
private String name;
private Date birthdate;
public int calculateAgeInYears () {
// use birthdate to calculate age
public static int getNumPersonsCreated() {
return numPersonsCreated;
}Here, the calc method cannot be static, since it uses the birthdate field that is particular to each Person object created. The number of Person objects created by your program, however, is not associated with any particular Person object, but with the Person class as a whole, so it can be static.Perhaps to expand a bit more...
Highly reusable methods are candidates for static such as utility methods that may be used multiple times.This is true if this methods API remains consistent and does not care a bout the surrounding class. Usually such a method would require all its fields to be provided by parameters or as static members as any instance variables would not make this methods reusable.
in jverd's example you can see that many related classes may be interested in finding out how many people have been created and they may wish to know so at the same time. It certainly makes sense to provide such a method as static as it does not change and most likely never will. More importantly all interested classes now are assured of seeing the exact same method because that is what static is: It exposes the same to all interested parties.
Edited by: Yucca on Oct 19, 2009 6:35 AM

Similar Messages

  • How to get caller object reference from a method

    Hi,
    I am working a already existing Java Swing project, now I got a problem, in a method I need to get the caller object reference otherwise, I can't succeed this operation. So please tell me a way how to get the caller object reference from a method. that method would be static or regular method anything will do for me.
    Edited by: navaneeth.j on Jan 29, 2010 11:20 PM

    navaneeth.j wrote:
    Actually my doubt is, I have a method "addition" method, which is using by many classes so my requirement is in the addition method I want to write a code snippet which will identify and get the the caller object. Actually I tried Reflection.getcallerclass but there I am getting "CLASS" object not the actual object reference, but I want object reference.
    Actually we have a huge project which is writen plain JAVA, so in this project the authors written the Database connection package for single database transaction. so now we are using this project source code for JSF application in this web application the DB package has serve based on the dynamic db connection parameters, so if we want to change this package fully means need to solve the dependency problem in hundreds of classes, so my point is if I can access the caller object in the DB package when ever it gets called by any class from any where of the project. So actually I liked Reflection.getcallerclass, the way of implementation perfectly works for me but it is not giving caller object reference, if something gives the caller object then I can get the DB connection parameters then there is no need to pass the parameters in the hierarchy.You can add a parameter (of type Object) to your addition() method
    and everywhere you call the addition() method also pass this (which from the POW of the addition() method will be a reference to the calling class instance).
    There may be alternative solutions
    but none that require less effort.

  • Call view method from componentcontroller method

    hello,
    how can i call a view method from componentcontroller method?
    thanks
    marcus

    Hi Marcus,
    As you said instance of view is already there when you are creating component controller's instance. So you work is done. You have to have event handlling mechanism.
    1. Create an event in your componentcontroller (Used component).
    2. Have a interface method in the same component controller. Now from you component you can call this method right.
    3. In the implementation of this interface method fire the event which you have created in step 1.
    4. Write eventhandler for this compnent's event in the view where actuall method is.
    So the moment u will call interface method of component it will fire component's event and it turn this event will be caught by the event hadler u have written in view.
    5. Now in implementation of this view's eventhandler call the view's required method.
    And job is done.
    Only thing event hadler of view will work only in case view is initialized in memory. As you said you have the view instance so no probs..
    Ask in case of any doubt.
    Regards,
    Neha Modi

  • How can I run my doclet from main method?

    I want to run doclet from main method.
    My source is:
    command = String.format("%s%s%s%s",
    "cmd /c ",
    "% javadoc -doclet ",
    "ExportJavaLib ",
    "-private " + dir.getAbsolutePath() + ".java");
    Runtime.getRuntime().exec(command);My doclet class file is in the same directory where is my class containing main method.
    I run the main class from bat file and set
    set CLASSPATH=%CLASSPATH%;D:\jdk1.5.0_06\lib\Tools.jarBut my code does nothing when it must execute the doclet.

    I've done it. 10x :)

  • Run KM from main method

    Hello,
    For some business reason I have to run and test KM functionality from main method.
    I need some examples
    1. how to connect to KM,
    2. how to create IUser and how to implement createUser method.
    3. how to instantiate IResource
    from main method.
    Any Help Will be greatly appreciated ...

    Hi Costa,
    Prior to using the code, give reference to the following jar files in your build path using the PORTAL_HOME variable name.
    bc.rf.framework_api.jar
    bc.util.public_api.jar
    com.sap.security.api.ep5.jar
    prtapi.jar
    Right click on your project, goto Properties > Web Dynpro References > Sharing References > Add > type <b>PORTAL:sap.com/com.sap.km.application</b>
    You may use the following code to get connected to a folder in KM and to create an instance of IResource.
    Assumption:
    The folder name being SPAP under the documents folder in KM.
    try {
    IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
    IUser sapUser = wdClientUser.getSAPUser();
    com.sapportals.portal.security.usermanagement.IUser ep5User =
    WPUMFactory.getUserFactory().getEP5User(sapUser);
    ResourceContext context = new ResourceContext(ep5User);
    RID rid = RID.getRID("/SPAP");
    IResourceFactory factory = ResourceFactory.getInstance();
    //get an instance of the current folder under which we have to create subfolders
    ICollection folder = (ICollection) factory.getResource(rid, context);
    ICollection newfolder = folder.createCollection(wdContext.currentContextElement().getQNtest(),null,null);
    // To get a resource from a folder
    //Assumption: template being the file under SPAP folder
    RID templateRID =RID.getRID("/SPAP/template");
    IResourceFactory fileFactory = ResourceFactory.getInstance();
    IResource templateResource =fileFactory.getResource(templateRID, context);
    //To create an instance of IResource
    //Assumption: We have a byte[] <b>inBytes</b> which corresponds to the content of a PDF/any file.
    ByteArrayInputStream dataStream = new ByteArrayInputStream(inBytes);
    //getting content
    IContent getContent =     new Content(dataStream, "text/XML", dataStream.available());               
    RID rid =     RID.getRID("/SPAP");
    IResourceFactory factory = ResourceFactory.getInstance();
    IResource resource = factory.getResource(rid, context);
    ICollection folder =     (ICollection) factory.getResource(rid, context);
    //"template" is nothing but the name of the resource that we are trying to create
    IResource resourceNew = folder.createResource("template", null, getContent);
    } catch (Exception e) {
    //  wdContext.currentContextElement().setTest(e.getMessage());
    Can you tell me why you want to create a user using IUser API?
    As you are deploying the code on your J2EE engine using the SDM user ID and password, it should take that authentication and access the KM folder in EP.
    Hope this helps.
    Regards,
    Rekha Malavathu

  • Calling a method from a method

    I'm having a big issue getting the method I am calling to use previously called 'programs' (for my lack of knowing the proper word.
    The myTurtle draws shapes as can be seen, after browsing the internet it appears to be a common learning mechanism.
    I'll link the code as a whole then my issue as well as my failed attempts at resolving the issue so that you hopefully don't have to read every line:
    All of it and the problem:
    It draws 5 separate graphs. When I call up "Turtle myTurtle = new Turtle()" it creates a graph for it to draw in. I want to be able to draw 5 things in the same graph not 1 thing in 5 different graphs.
    package lab04;
    import java.awt.Color;
    import galapagos.*;
    import java.util.Scanner;
    * @author Kyle
    public class Bars {
         * @param args the command line arguments
        public static void main(String[] args) {
            Scanner stdin = new Scanner(System.in);
            Turtle myTurtle = new Turtle();
            int input1 = stdin.nextInt();
            int input2 = stdin.nextInt();
            int input3 = stdin.nextInt();
            int input4 = stdin.nextInt();
            int input5 = stdin.nextInt();
            draw(input1, -200, -100);
            draw(input2, -120, -100);
        public static void draw(double a, double x, double y) {
            Turtle myTurtle = new Turtle();
            myTurtle.jumpTo(x,y);
            myTurtle.penUp();
            myTurtle.move(10);
            myTurtle.penDown();
            myTurtle.turn(90);
            myTurtle.move(a * 10);
            myTurtle.turn(-90);
            myTurtle.move(50);
            myTurtle.turn(-90);
            myTurtle.move(a);
            myTurtle.turn(90);
    }My problem locally:
        public static void main(String[] args) {
            Turtle myTurtle = new Turtle();Is not following through on my public static void draw side. All of the myTurtle commands are underlined red, meaning they aren't defined properly.
    This one just ends up drawing 5 separate bars when added to the called method.
    Turtle myTurtle = new Turtle();I then tried probably 20 variations of calling up Turtle()
    and my last attempt named the code up top in an attempt to call it below.
        public static void main(String[] args) {
            Scanner stdin = new Scanner(System.in);
            Turtle myTurtle = new Turtle(test);
        public static void draw(double a, double x, double y) {
            Turtle myTurtle = new Turtle(test);Which is also a complete failure.
    Sorry this was so long, I'm sure it is a really simple fix, I just cannot figure out what it is.
    Thanks for any help.

    >
    How do you expect us to provide proper help if you leave stuff out?It is unnecessary for the question at hand. Even if I were to have left the "Turtle myTurtle = new myTurtle()" out in the main method I would be drawing 5 boxes in 5 different frames whilst saving myself the blank frame.
    Here is all of it
    import java.awt.Color;
    import galapagos.*;
    import java.util.Scanner;
    * @author Kyle
    public class Bars {
         * @param args the command line arguments
        public static void main(String[] args) {
            Scanner stdin = new Scanner(System.in);
            Turtle myTurtle = new Turtle();
            myTurtle.speed(500);
            myTurtle.jumpTo(-200, 100);
            myTurtle.turn(-90);
            myTurtle.penColor(Color.BLACK);
            myTurtle.move(200);
            myTurtle.turn(90);
            myTurtle.move(400);
            int input1 = stdin.nextInt();
            int input2 = stdin.nextInt();
            int input3 = stdin.nextInt();
            int input4 = stdin.nextInt();
            int input5 = stdin.nextInt();
            draw(input1, -175, -100, 1);
            draw(input2, -100, -100, 2);
            draw(input3, -25, -100, 3);
            draw(input4, 50, -100, 4);
            draw(input5, 125, -100, 5);
        public static void draw(double a, double x, double y, int color) {
            Turtle myTurtle = new Turtle();
            if (color == 1) {
                myTurtle.penColor(Color.RED);
            } else if (color == 2){
                myTurtle.penColor(Color.YELLOW);
            } else if (color == 3){
                myTurtle.penColor(Color.GREEN);
            } else if (color == 4){
                myTurtle.penColor(Color.BLUE);
            } else {
                myTurtle.penColor(Color.PINK);
            myTurtle.speed(500);
            myTurtle.jumpTo(x,y);
            myTurtle.penDown();
            myTurtle.turn(90);
            myTurtle.move(a * 10);
            myTurtle.turn(-90);
            myTurtle.move(50);
            myTurtle.turn(-90);
            myTurtle.move(a * 10);
            myTurtle.turn(90);
    }As for the second part, yes I need one object. My issue is that everything I try is ultimately unsuccessful in getting 1 graph to be used.

  • Call Javascript methods from Java methods

    Dear All,
    I have a requirement where I need to invoke Javascript methods from a Java file located in the same machine. Are there any possible solutions for this?
    Regards,
    Alok

    Hi,
    Thanks for all your replies. Does this work on Java 5 too? Could you please share the complete code snippet which makes it work? I tried working on yours but no success.
    Regards,
    Alok

  • Calling a function from Main()

    I have a written a function which I want to call in the Main method:
    private static GetExcel()
    DataTable dt = getData();
    System.Data.DataView view = new System.Data.DataView(dt);
    System.Data.DataTable selectedCol = view.ToTable("selectedCol", false, "OWS_PName");
    StreamWriter wr = new StreamWriter(@"C:\\Sunny\\Directory.csv");
    try
    //Write Column names to Excel
    for (int i = 0; i < selectedCol.Columns.Count; i++)
    if (selectedCol.Columns[i].ToString().ToUpper().Contains("OWS_"))
    wr.Write(dt.Columns[i].ToString().ToUpper().Replace("OWS_", "") + ",");
    wr.WriteLine();
    //write rows to excel file
    for (int i = 0; i < (selectedCol.Rows.Count); i++)
    for (int j = 0; j < selectedCol.Columns.Count; j++)
    if (selectedCol.Rows[i][j] != null)
    if (selectedCol.Rows[i][j].ToString().Contains(";#"))
    wr.Write(Convert.ToString(selectedCol.Rows[i][j]).Replace(";#", "") + ",");
    else
    wr.Write(Convert.ToString(selectedCol.Rows[i][j]) + ",");
    else
    wr.Write("\t");
    //go to next line
    wr.WriteLine();
    //close file
    wr.Close();
    catch (Exception ex)
    throw ex;
    What should I return here and how should I call it in Main()

    Hi,
    As this question is more relate to C#, I suggest you post it to Visual C# Forum, you will get more help and confirm answers from there.
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=csharpgeneral
    Best regards
    Patrick Liang
    TechNet Community Support

  • How do I access array elements in one method from another method?

    Hi all!
    How do I access the array's elements from another method so that method 2 can have access to method 1's array elements? Thanks for any help!
    I am trying to create a simply program that will use a method to create an array and a SEPARATE method that will sort the array's elements (without using java's built in array features). I can create the program by simply having one method and sorting the array within that same method, BUT I want to sort the array from another method.
    Here's my code so far:
    public class ArraySort {
       public static void createArray(int size){
           double myArray[] = new double[size];    //create my new array
           for(int j=0; j < myArray.length; j++)
              myArray[j] = (200.0 * Math.random() + 1.0);   //fill the array with random numbers
       public static void sortArray(){
           // I WANT THIS METHOD TO ACCESS THE ARRAY ELEMENTS IN THE METHOD ABOVE, BUT DON'T KNOW
          //  HOW???? Please help!
        public static void main(String[] args) {
            createArray(4);    //call to create the array
    }Thanks again!
    - Johnny

    Thanks for the help all! I ve managed to get the program working, using java's built in array sort, but when i try to call on the array sort method from WITHIN my main method, nothing happens!
    Can somebody please tell me why I am not able to call on the sort method from within my main class???? Thanks!
    public class ArraySort {
       public void createArray(double[] arrayName, int size){
           double myArray[] = new double[size];  //create new array
           for(int j=0; j < myArray.length; j++)
              myArray[j] = (200.0 * Math.random() + 1.0);    //populate array with
           }                                                 //random Numbers
           sortArray(myArray); 
       } //Sort array(if I delete this & try to use it in Main method --> doesn't work???
       public void sortArray(double[] arrayName){
           DecimalFormat time = new DecimalFormat("0.00");
           Arrays.sort(arrayName);      //sort array using Java's built in array method
           for(int i = 0; i <arrayName.length; i++)
               System.out.println(time.format(arrayName)); //print arary elements
    public static void main(String[] args) {
    ArraySort newArray = new ArraySort(); //create a new instance
    double myArray[] = new double[0]; //create a new double array
    newArray.createArray(myArray,4); //build the array of indicated size
    //newArray.sortArray(myArray); //This will not work???? WHY?????//

  • Pass parameters into a method from other methods.

    I m testing  2 related applications with coded ui test and wanna pass a parameter from one method into another.
    how can i do that?
    Thank you in advance.

    Hi mah ta,
    Could you please tell us what about this problem now?
    If you have been solved the issue, would you mind sharing us the solution here? So it would be helpful for other members who get the same issue.
    If not, please let us know the latest information about it.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Problem when calling session bean from main.

    Hi everyone
    I get the following error when calling a session bean from main(String args[]).
    Sep 3, 2008 9:11:13 AM com.sun.enterprise.appclient.MainWithModuleSupport <init>
    WARNING: ACC003: Application threw an exception.
    java.lang.NullPointerException
    at databasetest.Main.main(Main.java:26)
    Here is my code beneath.
    I'm using netbeans and glassfish application server.
    Everything is in the same project, called DatabaseTest, I also have deployed the application before running the client.
    I'm running the client as follows, right click on the DatabaseTest-app-client and select run.
    The client:
    package databasetest;
    import com.test.UsersFacadeRemote;
    import javax.ejb.EJB;
    import com.test.Users;
    public class Main {
        @EJB
        private static UsersFacadeRemote usersFacade;
        public static void main(String[] args) {
            Users users = new Users(12, 34);
            usersFacade.create(users);
    }The remote facade I'm calling:
    package com.test;
    import java.util.List;
    import javax.ejb.Remote;
    @Remote
    public interface UsersFacadeRemote {
        void create(Users users);
        void edit(Users users);
        void remove(Users users);
        Users find(Object id);
        List<Users> findAll();
    }The stateless bean:
    package com.test;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    @Stateless
    public class UsersFacade implements UsersFacadeRemote {
        @PersistenceContext
        private EntityManager em;
        public void create(Users users) {
            em.persist(users);
        public void edit(Users users) {
            em.merge(users);
        public void remove(Users users) {
            em.remove(em.merge(users));
        public Users find(Object id) {
            return em.find(com.test.Users.class, id);
        public List<Users> findAll() {
            return em.createQuery("select object(o) from Users as o").getResultList();
    }

    looks like you're banging your head against the same brick wall as [I have done|http://forums.sun.com/thread.jspa?forumID=13&threadID=5317110] and [others have in the past|http://forums.sun.com/thread.jspa?forumID=136&threadID=5259913] if that's any consolation.
    Funny thing is, mine did actually work in the debugger but not when running!
    Strange thing that.
    I did initially interest someone from the developers but they couldn't really help, ended up saying : try instantiating your beans the EJB 2.1 way and see where that gets you. Yes that works but they promised us "hey no more dopey xml deployment descriptors just some cool annotations" didn't they?
    I've got the feeling were' missing something really obvious!
    Edited by: sebthebike on 03-Sep-2008 12:21

  • How to call a class from a method ?

    Hi,
    I have a Connection class and another class called 'B' class.
    class Connection {
    public static void main (String args[]) {
    try{
    Class.forName("...jdbcDriver...);
    String url="jdbc:...//localhost:.../DBName";
    Connection con=DriverManager.getConnection(url,"...","...");
    Statement stmt=con.createStatement();
    }catch (Exception e) {e.printStackTrace();}
    class B {
    public void someMethod {
    How do I call the Connection class to do this ?
    stmt.executeQuery(query);
    Thanks a lot !
    Phil

    Thanks !
    class Connection {
    public returnType Connection{
    Statement stmt=con.createStatement();
    return stmt;...
    ...main {
    class B {
    public someMethod {
    Connection conn = new Connection();
    conn.Connection.executeQuery(query);
    woah - what is that??
    And why make a new Connection here, I thought you did that in your Connection class (which is not a good choice of names, by the way, since it matches the name of the java.sql.Connection interface)
    Is this what you mean ? But, what is the returnType
    above ?You intend to return your stmt reference, right? So, the return type of that method has to match the type of thing you are returning, which is Statement.
    >
    Thanks !
    Philip

  • Calling a controller from the method "Do_request" of another controller

    Dear Friends.
      How are you?  I am trying to call  processForm.do controller from another controller's do_request method.. i dont want to use or assign view. i m not using view.  more-over i need to pass certain values to another controller... will it possible for me to do that.. please reply me... your any help will be appreciated..
    Thanking you
    Regards
    Naeem

    Hi Naeem,
    We are using the standard class cl_hrrcf_application_ctrl to retrieve the parameters. We have to pass the parameters which are need to pass from one controller to other controller. In the do_initattributes of receiving controller have to write the following code.
    DATA lo_appl_ctrl TYPE REF TO cl_hrrcf_application_ctrl.
    lo_appl_ctrl = get_application_ctrl( ).
          CALL METHOD lo_appl_ctrl->global_context->get_params
            IMPORTING
              p_hrobject      = ls_hrobject
              p_req_hrobject  = ls_req_hrobject
              p_cdcy_hrobject = ls_cdcy_hrobject
              p_act_guid      = l_act_guid.
    I think this can be use for erec applications. Like this we can create a class & get the parameters.
    Hope this wil Helpful.
    Thanks & Regards,
    Anita Vizhi Arasi B

  • Can we call super class method from Overwrite method using SUPER keyword

    Hi All,
    For one of our requirement , I need to overwrite "Process Event" method of a feeder class  ,where process event is present is protected method. so when we are making a call , then its saying
    "Method  "process event"  is unknown or Protected  or PRIVATE ".
        But we are just copied the source code in the "Process Event" method to the Overwrite method.
    Can anyone provide me the clarification , why system behaving like this.
    Thanks
    Channa

    Hi,
    I think you can not.
    Because, only public attributes can be inherited and they will remain public in the subclass.
    for further detail check,
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    regards,
    Anirban

  • Calling a variable from main class to other class

    How do I call a variable that is initialize in the Test.java into Sub.java?
    I want to call the a, b, c that I have initialize in Test.java into Sub.java.
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    public class Test{
         public static void main(String args[]){
              int b;
              int c=1;
              int a=11;
              b = c + a;
              System.out.println(+b);
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    public class Sub{
         public void Subtraction(){
              if(a>c)
                   b = a-c;
              else if(c>a)
                   b = c-a;
              else if(a=c)
                   b = a-c;
              System.out.println(+b);
    }

    This is, and I'm sorry but I don't know how else to say this, a real big mess.
    I'll go through some (most/all) of it but honestly....
    import java.awt.*;Many will tell you that you should use specific imports and not wildcards to increase ease of reading. I am not so personally picky about this but it would help you.
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*; Don't import things you never use. It just adds confusion get rid of java.util import
    import java.lang.Object.*;Redundant. Remove it.
    import java.applet.Applet.*;Unused. get rid of it
    public class SUBOK {      Terrible class name. Please use the standard [_Java naming conventions_|http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html]
    public int a = 10;
        public static void main(String[] args) {
             SUBOK runGUI = new SUBOK();
        public SUBOK(){
             JFrame f = new JFrame("Subok");
             f.setSize(150,100);
             f.setVisible(true);
             f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
             JButton b = new JButton("Sum");
             b.setActionCommand("send");
             b.addActionListener(new Push());
             JPanel p = new JPanel();
             p.add(b);
             f.add(p);
        } Most of that is okay although not great. But I don't think you should be doing anything in Swing at all yet.
      private class Push implements ActionListener{
             public void actionPerformed(ActionEvent e){
                  if(e.getActionCommand().equals("send")){
                       int a = 12;You are aware that this a has nothing to do with your other a? right? I mean this is a method local variable in a whole other class then the other one.
                           Add i = new Add();
                           i.Add();                
        public int aValue(){
             return a;
    } Alrighty then...
    import java.lang.*;Redundant. Remove You never need to import java.lang.
    import java.awt.*;Unused. remove.
    import java.util.*;Unused remove.
    public class Add {
         SUBOK a = new SUBOK();
         int d = a.aValue(); Aiaiaiai.
      public void Add() {
             int b;
             int c = 0;
             b = d+c;
             System.out.println(b);
    }First of all do not name a method the same as a class. Second most of this class appears to be based mainly in the realm of wishful thinking. In programming, wishing that something will "just work" without understanding the basics of why and how it works does, pretty much 100% of the time, not end well.
    You need to take a number of steps back from this code, get grounded in some fundamentals and then make another attempt. I would highly recommend putting the Swing (or any other GUI) code aside for some time now. Inter-object communication is a fundamental part of OO and thus a fundamental part of Java and this code clearly shows that you don't understand it yet at all.
    Start here [_Learning The Java Language_|http://java.sun.com/docs/books/tutorial/java/index.html]
    If you have questions as you go through the tutorial do come back and ask them and someone here will be glad to help you. But in order to help you with code you have to be at a point where you understand things like variable scope, the difference between a class and an Object and how, why and what methods can be used to exchange information between two instances.

Maybe you are looking for

  • Copying layers from one document to another

    Hi using Cs6, locked down all the layers I didnt want to copy across, select all, copy .. new document select paste remembers layers, paste in front, all layers beautifully copied but I cant see any of them on the artboard, only in the layers panel. 

  • Gmail started pushing mail on iPhone?

    Hi, I noticed a very strange thing yesterday. All of a sudden my Gmail account on my iPhone has started receiving push emails (this is a good thing). I found a bit strange that nowhere I read about it. I have push on (for Gmail calendars) and fetch '

  • Backup not happening at end of session in Lightroom

    Back up window is not appearing in Lightroom when I finish a session as it was before. I've no idea what I did to cause that to happen, and can't find how to fix it. I truly would appreciate some help to fix it, thank you. Kind regards, Warren.

  • A question regarding Virus protection..

    Hey! So my mac is about 2 years old now. I was wondering is there any virus protection programs that I should download to keep my Mac safe? Also, are there any viruses that CAN attack a Mac? As far as I have been using the mac there have been absolut

  • Is there a way to patch my Logic Pro 9.1.8? Or do I have to spend another $200.00 and purchase Logic Pro X?

    Just wondering if Logic Pro is like Pro tools where I can patch a newer version without paying full price.