0

I am trying to learn Java and am using Eclipse. For some reason the constructor I am using is not providing my Main class with the necessary information. Any help would be appreciated.

package com.wes.classes;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Ball ball = new Ball(mColor: "Blue", mName: "just ball", mCapacity: "12", mElasticity: "45");
        ball.Bounce();  
    }

}
package com.wes.classes;

public class Ball {


    //Properties of instance variables
    private String color;
    private String name;
    private int elasticity;
    private int capacity;

    public Ball(String mColor, String mName, int mElasticity, int mCapacity) {
        // TODO Auto-generated constructor stub
        color = mColor;
        name = mName;
        elasticity = mElasticity;
        capacity = mCapacity;
    }

    //Behaviors



    public void Bounce() {System.out.println("Bouncing");   }
    public void Deflate() {System.out.println("Deflate");   }
    public void Inflate() { System.out.println("Inflate");  }
}
greg-449
  • 109,219
  • 232
  • 102
  • 145
  • 1
    That is not how you call constructors. You simply pass the value or variable in as per the tutorials that are easy to find. [Constructor tutorial link](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) – Hovercraft Full Of Eels Mar 29 '20 at 16:40
  • Also read [Tutorial: Passing Information to a Method or a Constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html) – Hovercraft Full Of Eels Mar 29 '20 at 16:42

0 Answers0