MrThoe

Lecture Example

Sep 2nd, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class Variables extends ConsoleProgram
  2. {
  3. //GLOBAL VARIABLES --> OUTSIDE ALL FUNCTIONS
  4. String myName = "Karel the\n Dog"; //DECLARE AND ASSIGN myName
  5.  
  6. public void run() //public static void main(String[] args){
  7. {
  8. //LOCAL VARIABLES
  9. int luckyNumber = 11; //whole number
  10. double currentTemperature = 75.3; //Decimal
  11. boolean isStudent = true; //1 or 0 (True or False)
  12.  
  13. System.out.println(luckyNumber);
  14. System.out.println(currentTemperature);
  15. System.out.println(isStudent);
  16. sayMyName(); //CALL THE FUNCTION sayMyName
  17.  
  18. }
  19.  
  20. public void sayMyName()
  21. {
  22. System.out.println(myName);
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment