tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code05:38

Java variable scope 🌍

Bro Code ↗

From the creator

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); } } //**********************************************

Published 2020-10-13 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code