Journey to Java: Episode 2 “Data Types”

public class Practice {   public static void main(String[] args) {      int myFirstNum = 500;      int mySecondNum = 200;      int total = myFirstNum + mySecondNum; //700      int myLastNum = 1000 - total;      System.out.println(myLastNum);      //prints 300   }}
public class Main {
public static void main(String[] args) {
Integer myInt = 5;
Double myDouble = 5.99;
Character myChar = 'A';
System.out.println(myInt);
System.out.println(myDouble);
System.out.println(myChar);
}
}
byte byteNum = 10;
byte myNewByteNum = byteNum / 2;
byte byteNum = 10;
byte myNewByteNum = (byte)(byteNum / 2);
byte byteNum = 5;short shortNum = 10;int intNum = 20;long myLongNum = 50000L + 10 * (byteNum + shortNum + intNum);System.out.println(myLongNum);

Floating Point Numbers

//float
float myFloat = 5.25f;
//double
double myDouble = 5.25d;
//without using d or f after the declaration java will assume it is a double.

Char and Boolean

char myChar = '\u0040';
//myChar's value will be the letter 'D'
boolean myBoolean = true;

Strings

String myString = "Adam";
System.out.println("Hello, " + myString );

Takeaways

--

--

--

Student at The Flatiron School in Washington DC

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

Recommended from Medium

Getting started with Loom, Truffle and Unity

What is cloud storage?

Kubernetes for Sentry AI

Creating a screencast for installing and using a Social Auth implementer!

Five Top Kubernetes log monitoring tools

Ballerina Collections: Arrays & Maps

Unlocking Web3 Gaming with Moonbeam and the ChainSafe Gaming SDK

UDF In PySpark

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

GoF Design Patterns in Java- Creational

Where’s Java Going In 2022?

Introduction to Java: A Beginner’s Guide

Collections in Java