Journey to Java: Episode 4 “Java Basics and Methods.”

// you cannot do something like this
int int = 3;
int void = 25;
int highestNum = 10;
int newNum = 11;
if (newNum > highestNum){
System.out.println("you are higher than the highest number");
System.out.println("congrats");
}
int highestNum = 10;
int newNum = 11;
if (newNum > highestNum)
System.out.println("you are higher than the highest number");
int highestNum = 10;
int newNum = 2;
if (newNum > highestNum){
System.out.println("you are higher than the highest number");
} else {
System.out.println("you were not higher than highest number");
}
int highestNum = 10;
int average = 5;
int newNum = 6;
if (newNum > highestNum){
System.out.println("you are higher than the highest number");
} else if (newNum > average && newNum < highestNum) {
System.out.println("not bad");
} else {
System.out.println("this number is pretty low");
}
public class Practice {   public static void main(String[] args) {   }

//we want to write a new method here. Outside the main method but
//still inside the Practice class}
public class Practice {
public static void main(String[] args) {
int firstNum = 1;
int secondNum = 2;
}

public static void ourFirstMethodAddsNumbers() {
int total = firstNum + secondNum;
System.out.println(total)
}}
public static void main(String[] args) {   int firstNum = 1;   int secondNum = 2;   ourFirstMethodAddsNumbers(firstNum,secondNum);}
public class Practice {   public static void main(String[] args) {      int firstNum = 1;      int secondNum = 2;      ourFirstMethodAddsNumbers(firstNum,secondNum);   }   public static void ourFirstMethodAddsNumbers(int one, int two) {      int total = one + two;      System.out.println(total);   }}
public class Practice {   public static void main(String[] args) {      int firstNum = 1;      int secondNum = 2;      ourFirstMethodAddsNumbers(firstNum,secondNum);   }   public static int ourFirstMethodAddsNumbers(int one, int two) {      int total = one + two;      return total;   }}
public class Practice {   public static void main(String[] args) {      int firstNum = 1;      int secondNum = 2;      System.out.println(
ourFirstMethodAddsNumbers(firstNum,secondNum)
);
} public static int ourFirstMethodAddsNumbers(int one, int two) { int total = one + two; return total; }}
public class Practice {   public static void main(String[] args) {      int firstNum = 1;      int secondNum = 2;      
int calculation =
ourFirstMethodAddsNumbers(firstNum,secondNum);

System.out.println(calculation);
} public static int ourFirstMethodAddsNumbers(int one, int two) { int total = one + two; return total; }}

--

--

--

Student at The Flatiron School in Washington DC

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What Are Try/Except Statements in Python?

Possible Solutions to the Open-Source Dilemma

Code on computer monitor

Null Pointer Exception in Java

What happens when you type https://www.google.com in your web browser and press enter?

This is a good project so we should participate in it

Jenkins: A Complete Overview

5 Inspiring Notebooks of March 2022

Java Lambdas and the Garbage Collector [part 1]

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Adolfo

Adam Adolfo

Student at The Flatiron School in Washington DC

More from Medium

Core Java Interview Questions for Beginners

GoF Design Patterns in Java- Creational

Where’s Java Going In 2022?

Exception Handling in Java