Java Introduction to Variables and Primitive Data Types | Java Tutorial for Beginners

Published: 03 July 2021
on channel: Thomas Jadallah
209
4

Introduction to Variables in Java - Java Primitive Types Overview for Beginners -

Java primitive types hold data specified by the user, and the data held in these variables is mutable and thus can be modified. There are many types of primitive types in Java. Today, we will discuss how to declare and initialize a variable in Java, we will discuss bits, shorts, ints, longs, floating point types such as floats and doubles, characters such as chars, and boolean values, or switches, such as booleans. We will discuss how to change the value held by a variable and how to modify variable values using arithmetic functions in Java.


Code from Video:

public class Main
{
public static void main(String args[])
{

/*
Declaring Variables -
type variableName;
*/

/*
Initializing variables -
type variableName = value;
*/


//integers

byte b = 0;
//8 bits - stores nums and chars from ASCII Table
short s = 0;
//16 bits
int i = 0;
//32 bits
long l = 0L;
//64 bits

//floating points 0.0 54.4 10.9

float f = 0.0f;
//32 bits
double d = 0.0;
//64 bits

//characters

char c = 'a';
//16 bits - stores nums and chars from Unicode

//booleans

boolean bool = false;
//1 bit

//variable manipulation

bool = true;
i = 10;
i = 20;
i = 10 + 10;



//you can change the values of variables easily


//you can also use multiple variables to do basic math functions

int numOne = 5;
int numTwo = 10;
int num = numOne * numTwo;
// num = 5 x 10 : * - + /
//* - + /



}
}

If you have any questions, let me know in the comments!

Subscribe: https://bit.ly/3bifwQC

Why you should subscribe:
Here we cover all the latest and greatest Apple products and accessories, jailbreak tweaks, and more
We consistently upload high quality content such as product reviews and tutorials
We also cover the latest new iPhone features and big iOS updates
And finally, we cover great jailbreak apps and jailbreak setups

Follow my Instagram for a sneak peak at future content before its uploaded to YouTube: https://bit.ly/35N3JIX
.
.
.

Timestamps:
00:00 Intro to Variables in Java
1:02 Declare and Initialize Variables in Java
2:40 Different Types of Primitive Data Types in Java
7:20 How to Change Values of Variables in Java
8:34 Basic Arithmetic Functions Using Primitive Data Types in Java
12:18 Quick Takeaways From This Video
12:59 Outro


Watch video Java Introduction to Variables and Primitive Data Types | Java Tutorial for Beginners online without registration, duration hours minute second in high quality. This video was added by user Thomas Jadallah 03 July 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 209 once and liked it 4 people.