mercredi 31 juillet 2019

Is there a way to call a public int from another class?

Is there a way to use a non static public int in another class?

I want to have classes where I have useful functions and static information that I use in many other classes in different packages.

info.longrandom

Does not work because it is non static.

package common.info

public class info {
public int veryshortrandom = (int)(Math.random() * 500 + 1001);
public int shortrandom = (int)(Math.random() * 1000 + 2001);
public int mediumrandom = (int)(Math.random() * 1500 + 3001);
public int longrandom = (int)(Math.random() * 3000 + 6001);
public int verylongrandom = (int)(Math.random() * 6000 + 1201);
}

I am hopeing for something that would be akin to:

return info.longrandom




Aucun commentaire:

Enregistrer un commentaire