What does the 'Static' keyword do?

I have a program where there are two shapes Player1 and Player2, both inherited by the class Player.

Public class Player{

    public int xPos;
    public int yPos;

    // more code


The player1 class:

Public class Player1 extends Player{

    public Player(){
        xPos = 200;
        yPos = 200;
    // more code

The Player2 class:

Public class Player2 extends Player{

    public Player2(){

        xPos = 400;
        yPos = 200;
// more code

In this case, should I use static for the xPos and yPos in the Player class?


If xPos and yPos were static, every instance of a Player would have the same position.

No. Static variables are members of the class, you want your position variables to be members of the object (non-static).

Need Your Help

How does AngularDart dependency injection work?

dependency-injection dart angular-dart

I have an component that needs to access its root element from the Dart code. By reading Differences between Angular.js and Angular.dart? here on SO and grepping around in the AngularDart source co...

bug in ionic official ToDo example

android ios cordova ionic-framework ionic

Ionic's official ToDo example (http://ionicframework.com/docs/guide/building.html) seems to have the bug that the modal that pops up asking for a Project name has "index.html" displayed on top of "