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

Learn to code by making a 2D space shooter game.

Tutorial: Generate Microsoft Visual Studio Solution for VTM+360Lib— 360-Degree Video Using VVC…

Databases Online

Expiration With DynamoDB TTL

TTL date time popup

SAP on Google Cloud (pt. 4): Secrets in your pipes

The Key Attributes of a Successful Software Outsourcing Vendor Relationship

jenkins installation with docker

SAML 101 : Lets write a Service Provider

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

JAVA JDBC

Resources to learn Java

Amazing Ways You Can Use Java

What is java?