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

Network Policies in Kubernetes

Utah Lawyers

utah lawyers

Welcome, Pedro!

My Journey of Passing AWS Certified Machine Learning Specialty Exam

Ovo’s Rustic Resource Pack 1.15.2–1.14.4 for Minecraft

Learn How to Become a Full Stack Web Developer

Introduction

A Shameless Plug for Shameless — Engineering Our Schemaless Data Store

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

Resources to learn Java

JAVA OOPS and IO

JAVA OOPS CONCEPT

Let’s talk about head first Java