Yay Java Time + Computer Science Time
Why I Made This Course
Basically school's starting again. (Yay) That means schoolwork. I'll be taking AP Computer Science, and Java is required to learn. So bear with me on Java.
This isn't just about Java, but computer science in general so feel free to watch this
I will not cycle squeeze.
I will get to the point
Long series.(pretty long)
Two. Just don't be toxic in the comment section
Set up your development area. wait... this is REPL. Just make a new JAVA repl.
(@wuru want to help make the series?)
@Bookie0 wanted this
Yay! Chapter One of Java!
History on Java
Quoted from Wikipedia so very reliable
"Java is a general-purpose programming language that is class-based, object-oriented, and designed to have as few implementation dependencies as possible. It is intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but it has fewer low-level facilities than either of them. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client-server web applications, with a reported 9 million developers." - Wikipedia
Yes, Java is the MOST POPULAR language.
Why Java? Minecraft. Want to mod minecraft? Learn Java.
AMAZON uses Java
EBAY uses Java
Big Companies use Java
I use Java
Squid likes to use Processing Java (way different I wouldn't reccommend leraning it other than games)
Java is SUPER popular(read wiki statement above)
anyways, lets START
Primitive Data Types
Primitive data types are the most basic data types available within the Java language. There are 8. byte, short, int, long, float, double, char, and boolean. (String is not included for it is not a primitive data type.) All data in Java goes in one of the two categories: primitive data and objects. Again, there are only 8 primitive data types. However, java has many types of objects, and you can invent as many others as you need. Any other data type you invent will be a type of object. (Java is a object oriented language ya know) For know, this is all you need to know.
- A primitive data value uses a small, fixed number of bytes.
- There are eight primitive data types
- you can't make more primitive data types.
- A object is a big chunk of data. A(n)? object may uses lots of memory.
- A object consists of a lot of other pieces(Like legos)
- Data type of an object is called a CLASS(lowercase but I'm too lasy to hit backspace)
- Classes are basically forced in Java (Yay java you are the best)
Bits, and more Bits.
If you noticed, you would've realised that six of the eight primitive data types are numeric types. Numbers are very IMPORTANT. There are both integer and floating point primitive types/number types.
(amasad add flow chart support pls)
Integer types are basically whole numbers, and floating point types are basically decimal numbers.
Integer Primitive Data Types
Type | Size | Range
byte | 8 bits | -128 to 127
short | 16 bits | -32k to 32k
int | 32 bits | -2 billion to 2 billion
long | 64 bits | -9e18 to 9e18
Floating Point Data Types
Type | Size | Range
Float | 32 bits | -3.4e38 + 3.4e38
Double | 64 bits | -1.7e308 to 1.7e308
Very big numbers!!!
All primitive type uses a fixed number of bits. (!!!Very important)
This means that iif you are using a specific data type, then the same number of bits will be used no matter what the value is.
For example, the value in int data type uses 32 bits. The value 1 and the value 20000000 all use 32 bits no matter the number.(Same goes with negative)
Values that are very large need more bits to be represented, or else the computer will not evaulate the number correctly.
Preferabbly, you will long for larger numbers and int for all regular numbers.
More bits and More Range
Think of a Tesla. If you want to get more range, you pay more money. The same goes for these operators. (Except there are free! Yay!) if you want to use a larger number, you have to use a bigger number type. If the number is 15987453584538, then you would want to use long but usually, int for integers, and double for decimal numbers should be enough.
If you want to use long, this 64 bit literal needs a upper case L or lower case l at the end for it to work.
NEVER use lower case l for it looks almost EXACTLY like 1. (See?)
Sometimes you need to explicitly ask for a single-precision float literal.
Other primitive data types
Sometimes you don't just have numbers, you also have characters. The primitive data type for characters in Java is named
char chars can only store one character.
characters have a single character with a apostrophe on one side.
'H' 'a' 'h' 'a' 'Y' 'e' 's' YOU CAN ONLY USE ONE AT A TIME
There are such things like control characters, like '\n' amd '\t' which gives a new line or a tab, but these are controllers, which we currently don't need.
Another primitive type is called boolean. It is used to represent true or false value.
Quick history lesson
boolean is named after George Boole, because he found that you could do a lot of stuff with true/false stuff.
Yayyyyyyyy its finally over
I'll be putting a quiz soon in the share place.
There will be a link here soon
Please Upvote! (because I just hit 1000 cycles so hehe)