Загрузка страницы

Java variable scope 🌍

Java variable scope

#Java #variable #scope

//**********************************************
public class Main {

public static void main(String[] args) {

//local = declared inside a method
// visible only to that method

//global = declared outside a method, but within a class
// visible to all parts of a class

DiceRoller diceRoller = new DiceRoller();

}
}
//**********************************************
import java.util.Random;

public class DiceRoller {

Random random;
int number;

DiceRoller(){
random = new Random();
roll();
}

void roll() {
number = random.nextInt(6)+1;
System.out.println(number);
}
}
//**********************************************

Видео Java variable scope 🌍 канала Bro Code
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
14 октября 2020 г. 3:46:04
00:05:38
Яндекс.Метрика