+ 1

What is the difference between private static int kilos and private int kilos (ignorr the name of the variable is just an example)

22nd Apr 2017, 1:25 AM
Isaac
Isaac - avatar
3 Answers
+ 2
when a class field is static it means its the same for all the objects you will create. for example if you have a class with an int age and a static int factor then every object you create can have a different age but all of them will have the same factor even if you change the value of factor using one object
22nd Apr 2017, 1:30 AM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
+ 2
static can be changed out of class. static final cant be changed
22nd Apr 2017, 1:37 AM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
0
static can't change out of class but dinamic ones can.
22nd Apr 2017, 1:33 AM
Mustafa Kenliç
Mustafa Kenliç - avatar