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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 3 of 3

Thread: Calling A Public Static Void Method from Main

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Calling A Public Static Void Method from Main

    I am working on a the Grid world code Bugrunner. Here is what I have so far:

    import info.gridworld.actor.ActorWorld;
    import info.gridworld.actor.Bug;
    import info.gridworld.actor.Rock;
    import info.gridworld.grid.Location;

    public class c5e01
    {
    public static void main(String[] args)
    {
    ActorWorld world = new ActorWorld();
    world.add(new Bug());
    world.add(new Rock());
    world.show();
    moveBug();
    }

    public static void moveBug(Bug a, int n){
    for(int i = 0; i < n; n-=1){
    if(a.canMove()){
    a.move();
    } else {
    a.turn();
    }

    }
    }
    }

    The bolded part is where my issue is. Eclipse is telling me that i am invoking the method wrong. Can anyone help me invoke my moveBug method from main?? Please and thank you


  2. #2
    Member Kewish's Avatar
    Join Date
    Apr 2013
    Location
    Australia
    Posts
    116
    Thanks
    10
    Thanked 17 Times in 14 Posts

    Default

    It requires two parameters

  3. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Calling A Public Static Void Method from Main

    Ehrm, sorry.

Similar Threads

  1. Replies: 4
    Last Post: June 6th, 2013, 10:30 AM
  2. Java, calling another public class from within the main class giving problems.
    By RandomGaisha in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 26th, 2012, 02:30 PM
  3. public static void main(NewMember Mr_Bukkake){ }
    By Mr. Bukkake in forum Member Introductions
    Replies: 2
    Last Post: October 13th, 2011, 07:29 AM
  4. Error using public static double Method
    By stommy989 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 13th, 2010, 03:01 PM
  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