quick java question about ints

gavin101

Onyx user!
Reputation
0
Hey guys, I'm working on my 1st script which is a iron power miner. I want to make an int for the pickaxes. Instead of making 5 different ones, how do I give one int more than one value.

I was suggested to make it look something like this:

int PickAxe values = { 1265, 1267, 1269, 1273, 1271, 1275, 15259 };

The code above is giving me errors and I can't remember how to do this. Any help is appreciated, thanks!
 
gavin101 said:
Hey guys, I'm working on my 1st script which is a iron power miner. I want to make an int for the pickaxes. Instead of making 5 different ones, how do I give one int more than one value.

I was suggested to make it look something like this:

int PickAxe values = { 1265, 1267, 1269, 1273, 1271, 1275, 15259 };

The code above is giving me errors and I can't remember how to do this. Any help is appreciated, thanks!

You are mostly correct, but it should be like this:
Code:
int pickValues[] = { 1265, 1267, 1269, 1273, 1271, 1275, 15259 };
And a word of advice, in java when naming variable, if the variable consists of two or more words, most people make the variable like this:

int moreThanTwoWords = 0;//(first word is uncapitalized) and spaces are not allowed

and when declaring something with more than one value, we use an array, which is when you have to add '[]' after the variable name.
 
Hacks said:
gavin101 said:
Hey guys, I'm working on my 1st script which is a iron power miner. I want to make an int for the pickaxes. Instead of making 5 different ones, how do I give one int more than one value.

I was suggested to make it look something like this:

int PickAxe values = { 1265, 1267, 1269, 1273, 1271, 1275, 15259 };

The code above is giving me errors and I can't remember how to do this. Any help is appreciated, thanks!

You are mostly correct, but it should be like this:
Code:
int pickValues[] = { 1265, 1267, 1269, 1273, 1271, 1275, 15259 };
And a word of advice, in java when naming variable, if the variable consists of two or more words, most people make the variable like this:

int moreThanTwoWords = 0;//(first word is uncapitalized) and spaces are not allowed

and when declaring something with more than one value, we use an array, which is when you have to add '[]' after the variable name.

Thanks for the help Hacks. I knew about not using more than one word but thats the code someone told me I should use.
 
Back
Top