Learn Java in 25 minutes | Java Tutorial for Beginners
Video Title: Learn Java in 25 minutes | Java Tutorial for Beginners
Hey hackers welcome back to my channel today we are gonna be looking at Java and if you are coming from c-sharp or C++ or Python I’m gonna show you how to create a Java program by just knowing some of the basics of programming and how programs work all right so the first
Thing we’re gonna do is you’re gonna open two tabs one is gonna be Java download and another one is gonna be IntelliJ download and so there are two downloads you’re gonna have here one is downloading Java itself and so we can build and develop Java programs and get
Them to run on our computer we want to go to downloads here and you’re gonna want to download twelve point zero point one I already have Java on my computer so I’m not gonna be downloading this if you’re using an older version of Java you’re welcome to do that too you need
Java in order to build Java programs and more importantly you need the java jdk in order to develop java programs on your computer and so you have the Java JRE this is what you use to run Java programs and the JDK has that built in
But it also lets us develop it if you want to do anything with Java and building and programming you need the JDK and it’s free you download it and then the second thing you’re gonna download is the IntelliJ IDE and it says idea but it’s IDE it’s integrated development environment and this is
Great because it’s a tool that we’re gonna use to build java code you could build a bunch of other things as you see in this animation here but it’s a great tool that’s gonna help us run our code the IDE is not required but it is a
Really awesome tool to use the JDK is a requirement when you open it up it’s gonna look something like this nice loading area we are going to create a new project and this is gonna allow us to create a new Java project here we have job at 12 we don’t need any of
These libraries we hit next next next we are gonna call this hello world because we’re learning how to do Java and you say hello to Java and this is gonna load up a little bit and what we’re gonna do is we can click hello world here we’re gonna go to source it’s gonna
Open up a little file navigation there that’s great we’re gonna create a new Java file with ctrl click new Java class we are gonna call this hello Java this is a Java file that we’re creating all right so we have this public hello class
In Java the first thing we need to do is add something called a main method and so we’re gonna go public static void main string args now we have a main method and now our program is executable so when I execute or run this program anything inside of here that is going to
Be executed so we’re gonna start off with a little print statement here so first thing is like how to print we’re gonna go system dot out dot println hello world this is our hello to Java in Java we have semicolons at the end of everything and so we gotta
Remember the semicolon or you will get errors the capitalization for system dot out dot println does matter it has to do with accessing libraries and methods and classes and all of that good stuff which we’ll learn about in a little bit so we’re doing ctrl click on hello we
Clicked hello dot mean and we are running that method and we see our hello world right there in the console now what else can we do with Java sure we printed hello world but we could do things like variables we can create them and so how do you do a variable in Java
Well you do something like it’s num num will call num equals 5 this is creating a number in Java we’re giving it the value 5 using the assignment operator and that variable has the label num and so it has the name num so we can refer it into our program when I mean
Referring to it we can go system dot preneur let pat out lin know 5 this is displaying it to our little window down here and we don’t want to put 5 in there we want to put num because value of num can change at any time and
We can press play up here now since we’ve run the file once and we get five in that terminal so we can have numbers we can have integers integers pull numbers int it’s a whole number you couldn’t put like 5.0 it freaks out because it’s like ah you found it double double decimal
Numbers and so we can go double double e so we’re creating another variable called doubly it has the datatype double and we’re giving it the value for point six so we can have whole numbers in our programs we can have decimal numbers in our programs we can also have something
Called two strings or text as a datatype in our programs we could do something like string name equals Catherine so this is my name my name is Catherine and we got to remember those semicolons my name is Catherine and we are putting that into our program we are storing
That information in our program with the variable that is named name and that variable is of a string datatype we can also have true and false values so these are the main values we can say is home and I’m gonna say true because I’m filming this at home and we go true with
A lowercase T not an uppercase T like our Python users we do true with a lowercase you could also say false here there are only two options because a boolean is a 1 or a 0 is a true or false value so we have in Java so far we have
Our variables we have our integers our doubles we have our strings which are characters and so you see each of these is a character that we can represent with a char first initial and we can call it ok with single quotations whereas this got a run home to the
Semicolons man or is this is with double quotations in other languages that doesn’t really matter in Java it does and so we have these double quotations for our string a string of characters a series of characters in a order that does matter or we can have characters individually we call them chars these
Are the different types of data we can store right now in our programs now we can print some stuff out we’ve printed out num but what happens if I print out and I don’t just print it like I do in Python I go system dot out dot println
And then we go system dot out dot println for all of these for the name we can do the initial as well for EE and the reason it has this like little underscore is because I may be misspelled things and that’s totally fine but it’s also because it’s not used
Within the program so right now first initial is not used in our program so all we do is create it we don’t reference it again so we don’t use that in our program again and that’s the reason you would want to create a variable is if you want to use a
Specific piece of data throughout your program that’s when you need a variable there and we can also print out is home on that next line right there we’re gonna go is home done run it and we get all these great things in our little display we have 54.6 Catherine 4.6 again
Because I totally forgot I already use EE and then we have my name and then 4.6 and then k and then false so we can display all of these things displaying is it that great no no it’s not but what if we could add a little bit of control
Flow into our program so what if we could add like if the name is Catherine I want to display this thing otherwise I want to display this thing so my everything is kind of coming up and so we say if name that equals Catherine then I want to print out
Happy birthday I want to show happy birthday to the user cuz my birthday’s coming up otherwise if my name does not equal that and then I want to print have a nice day and that’s it that’s the end over the game so I’m going to do something called
Commenting and so that is basically disabling a piece of code so that it isn’t run by the computer we’re gonna save this we’re gonna run again and if my name equals Katherine then this is gonna print out and in fact my name is Katherine and so we print out happy
Birthday so with this we had our if-else statement this is what we call these things if a certain condition is true in this case if my name is Katherine then I want to do this block of code otherwise if my name is not Katherine something else then I just want to say
Have a nice day now let’s say my I put cat in here that’s kind of like Katherine will execute will it run happy birthday well no it will not because it’s not exactly my name same thing if I did Katherine with a lowercase like that’s that’s not gonna be a problem
Because I’m gonna get have a nice day again and so these are certain things to think about when you’re programming so what other conditions can we put in here I did dot equals because that’s something you can do with strings we have different datatypes right we had our integers our doubles our characters
Are strings our boolean and with those different data types we have different operations we can use on them equals is one of those operations another thing we can do here is let’s make another if statement here we’ll say if num is less than 18 we can print out you are not an
Adult so with numbers we get something called conditional operators or relational operators we’re talking about the relationship between the value of this variable num and a teen or asking the question if the number num if that value is less than 18 then I want to run
This code if num is greater than or equal to 18 then we just skip the code altogether I could have added an else block here but we’re not doing that we only want to print out something if num is less than 18 so right now num is 5 if
We run this we will get B you are not an adult in our console and that is what we see here the console it’s just this little window down here it’s called lots of different things that display we’re calling at the console here for this condition I could have also done less
Than or equals to I could have done greater than I could have done is equal to and I could have done a double equal for saying is num equal to 18 what does that equality look like if the condition is true then we run the block of code if
The condition is not true we do not run that block of code we could have also done not equals here so if num does not equal 18 then I want to run the code these are different operators that I can put inside of here to continue the code
I could have also done something like this is home if I’m home then you could say this block of code here if I’m not home you could do that by adding that explanation point there whatever is in these parentheses just has to be a condition we can also combine conditions
And create more complex conditions so we can say if the person is not home and the age or the num is less than 18 then I want to do something so if I’m not home and the num is less than 18 then I want to run this both of these have to
Evaluate to true in order for us to evaluate this block I could have also done or if one of these things is true then I want to execute this code if none of them are true then I want to do something else whether that’s just continue with the code down below or
Execute an else block these conditions become pretty important because we can also have things called loops we gonna have a while loop and we’ll say while num is less than 18 I want to say you are not an adult and I want to increment none so here we have num plus plus we
Could also have done this num plus 1 but this looks like kind of annoying so we do num plus plus instead so we’ll comment this out we’ll go down plus plus and there we go so here we say while num is less than 18 I want to run this code
So what happens here nom is 5 right now and so 5 is less than 18 so then we go and we run this code we print out you are not an adult and then we increment num this means when I check the condition again so I’m gonna go back up
Here while so while these things continue to be true I want to continue to execute this block of code within these curly braces so we have parens surrounding our condition in curly braces surrounding our code that we want to execute the conditions we saw up here
Or we did is not home these things these can also be brought down here so we could have done this as well however once this condition is not true when I check it again so if I go a system dot out dot println you’re not an adult
Let’s say the number was 17 we increment it it’s 18 we get 18 less than 18 that is not true now we’re jumping out of here and we continue with the rest of the code another thing of course is if you for some reason never increment increment
Num so that this would never be false and so say this is always going to be true then we’re gonna be stuck in this while loop forever and you’ll get prince and Prince and Prince and Prince there are also other types of loops we can have we can have something called a for
Loop where we go for int I equals 0 while I is less than say 20 I plus plus so what this is going to do is it’s going to say well I’m gonna create a variable called I I’m gonna set it to 0 and then I’m gonna say while 0 or I is
Less than 20 I’m gonna increment I and win before I increment I’m gonna do all of this code so in this case I could print I or system data print up this is another type of loop that we can do so if I run this code we’re gonna get a
Bunch of other stuff kind of coming with us because and so here we’re actually getting that wild thing because I did not Rianne criminal and so we’re getting stuck in this infinite while loop and then your program crashes and that sucks so we are going to stop the
Program we are going to come at that but we are going to run again and you’ll see it working this time here we go we print out all of those numbers starting from 0 going all the way to 19 because once we hit 20 this block of code is not going
To be executed this print because that condition is no longer true 20 gives not less than 20 and so we jump back down to this part of the program which right now has nothing which is why the program exits the program exits by itself you don’t have to do anything as long as
Your code is connected to this main function you’re good to go and it will execute when you run the file there are also things called a do-while loop so you go do this piece of code while like num is less than 18 or while we’ll create another variable called X it’s
Airing because if we don’t we don’t tell it what X is we have to tell it X is 10 or X is zero and we got to make sure we put the datatype that it’s an integer and so we could say dot out dot println happy 4th for happy 4th of July
Save that up and then this would continue to print while X is less than 10 in fact it would print forever because we do not an increment X so that this condition will be false at some point in time now that we have incremented X we can run this code again
And we’ll see happy fourth printing out ten times and so we see this in our console here so what have we done so far we know how to do print statements we know how to do variables we know how to do conditionals if-else conditions all
Of that good stuff and so how do we get something to evaluate to true or false so our programs can make decisions and we also have wild loops for loops while loops do-while loops all of that good stuff in here so these are your basic tools what do you do now the
Some of the basic syntax we had semicolons at the end of our statements we have parentheses for the conditions of our wiles we have curly brackets surrounding the code to be executed if the condition is true we have this else block if the condition is false all of this code out
Here it kind of sucks right like it’s all in this one big blob that’s why we create something called functions and so we can go public static in this case we’ll go int double and in this case we’ll double a number we got to put our
Data type for this which is gonna be an int we’re actually gonna call it double e because double is a keyword in Java because we use it here for our D the type so we call it doubly and we’re actually gonna take away a lot of this
Code we’re gonna just delete it you have it in your memory so we’re good to go here and so what we’re gonna do is inside of here we’re actually gonna go return x times X and what that means here is we can go int double equals EE 5
So what this is like is it’s like in math where you go f of x equals x times X and then you’re calling now F of 5 which now becomes 5 times 5 and that’s how we get this we call 5 an argument we call X the parameter EE is the name of
Our function it’s a set of instructions that I can reuse repeatedly we have an int and integer we have static you have to go a little bit deeper into Java to know what that means but it allows us to run the code inside of our main function directly versus creating an instance
Where you jump into like object orientation which might be a part two of this when we say return we mean that EE 5 will evaluate to you whatever x times X is which in this case is 5 times 5 which would give us 25 so we are going
To system dot out dot println doubled save run the thing and we are gonna see 5 doubled 25 in our console because we called this function ee the set of instructions that we have labeled ee the set of instructions are right in here and we give it our
Argument 5 that is what X becomes that’s what the value of x is going to be it’s going to be 5 because we are using the function we’re calling the function with 5 vs. defining the function which is what we did up here so we define a
Function we can use the function we can call the function with EE 5 5 is the input we’re giving to our function int X here allows us to give EE that input and we can call it again with other doubled we can create a new
One call it 10 so this will multiply 10 times 10 because we’re giving X the value of 10 we double it up inside of here because that is what our instructions tell us to and then we can print it out to our console with system dot out dot println we’ll go ahead and
Run the code see what happens we have 25 for our first double and 100 for our second double because that is what our instructions tell us to do here with Java we have lots of operations we can do we do x times X for multiplication we can do X plus plus to
Increment or add 1 to X and so if X is 10 this becomes 11 we can go – – to decrement so if X was 10 we would get 9 we have to have that semicolon at the end we could also do X divided by 4 so
We can do division we can also do subtraction like this so when you go – 5 we could also go + 5 these are the basic operations you need to know about numbers and how they work in Java we can also with our strings we showed you how
To make two strings asked if they were equal to each other there are also other operations so I’m going to bring back my string name we’re calling it a Catherine here if I go name dot this is the power of an IDE here are all the different things you
Can do with a string you can say what is the character at index zero indexing is a whole other story but basically this is saying okay go ahead in return okay so if I go char first initial this is what that returns if I wanted to get the last character in
My string name I could go name dot link minus one and this would get me the last character length in char at are two operations we can use on name to experiment with others you can go name dot see all the different ones that you
Can use is empty is a great one that tells you if there’s anything in the string so are there any characters including spaces in that string like what is the length how many characters are in my string there’s a lot of replace and so if you want to replace
Characters in your text we have something for that and this takes practice we also have to lowercase and notice it has this string here so it’s going to return name but lower cased it’s gonna create a new string for us and so we can go string lowered equals
Name to lowercase and we would get Katherine all in lowercase in our console if we decided to print that out now you can go and experiment with all of these different tools that I just showed you very quickly with Java but what did we cover here we showed you
How to print to the terminal or print to the console in this case this little window down here we talked about variables and why you would use a variable and how it labels your data so you can reference and send the code we talked about data types and so we had
Our ends our floats our doubles all of that good stuff and we put them in our code we talked about conditionals and how a conditional is something that returns a true or false value we put those conditions in our if-else to help with decision making we had while loops
We had for loops we had do-while loops which allowed us to repeat a series of code state then we also looked at functions we looked at parameters arguments the function name return types all of that good stuff wrapped up in a package in this video I also make Java courses with
LinkedIn learning those are a little bit more in-depth if this was a little bit too fast paced so be sure to check out those linked down below linked on learning linked down below so I hope you liked it let me know in the comments and happy hacking
-
Sale!
Wireless WIFI Repeater Extender Amplifier Booster 300Mbps
$29.99$14.99 Add to cartWireless WIFI Repeater Extender Amplifier Booster 300Mbps
Categories: Electronics, Wi-Fi Router, Wireless Wi-Fi Extender Tags: 300Mbps, 802.11N, Amplifier, Booster, Extender, mobile wi-fi booster, Remote, WIFI, Wireless, Wireless WIFI, Wireless WIFI Repeater, Wireless WIFI Repeater Extender, Wireless WIFI Repeater Extender Amplifier, Wireless WIFI Repeater Extender Amplifier Booster, Wireless WIFI Repeater Extender Amplifier Booster 300Mbps$29.99$14.99 -
Sale!
Full RGB Light Design Gaming Headset Headphones with Mic
$24.99$14.99 Add to cartFull RGB Light Design Gaming Headset Headphones with Mic
Categories: Electronics, Gaming, Gaming Headsets Tags: Design, Full, Full RGB Light Design Gaming Headset, Full RGB Light Design Gaming Headset Headphones, Full RGB Light Design Gaming Headset Headphones with Mic, Gamer, Gaming, Gaming Headset Headphones, gaming headset wireless, Headphone, Headphones, Headset, Light, Mic, Package, RGB$24.99$14.99 -
Sale!
Wireless BlueTooth Multi-Device Keyboard Mouse Combo
$39.99$19.99 Add to cartWireless BlueTooth Multi-Device Keyboard Mouse Combo
Categories: Electronics, Gaming, Gaming Keyboards, Keyboard Mouse Combos Tags: Combo, Keyboard, keyboard mouse combos, Mouse, MultiDevice, Set, WireKeyboard Mouse Combo, Wireless, Wireless BlueTooth Keyboard Mouse Combo, Wireless BlueTooth Keyboard Mouse Combos, Wireless BlueTooth Multi-Device Keyboard Mouse Combo, Wireless BlueTooth Multi-Device Keyboard Mouse Combos$39.99$19.99 -
Sale!
High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
$199.99$139.99 Add to cartHigh Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
Categories: Gaming, Gaming Chairs Tags: Adjustable, Chair, computer chairs, Desk, Executive, Gaming, Girl, Headrest, High, High Back Leather Executive Adjustable Swivel Gaming Chair, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar, High Back Leather Executive Adjustable Swivel Gaming Chairs, Leather, Lumbar, Office, Racing, Swivel$199.99$139.99 -
Sale!
Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
$29.99$19.99 Select optionsProfessional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
SKU: N/A Categories: Electronics, Gaming, Gaming Headsets Tags: Cancelling, Gaming, Gaming Headphones with Noise Cancelling Microphone, gaming headset, Headphones, Headset, LED, Light, Mic, Microphone, Noise, Professional, Professional LED Light Wired Gaming Headphones, Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone, Wired, Wired Gaming Headphones, Wired Gaming Headphones with Noise Cancelling Microphone$29.99$19.99 -
Sale!
Gaming Desk with LED Lights USB Power Outlets and Charging Ports
$349.99$249.99 Select optionsGaming Desk with LED Lights USB Power Outlets and Charging Ports
SKU: N/A Categories: Computer Desk, Gaming, Gaming Desk Tags: and Charging Ports, Charging, Desk, Desks, Gaming, gaming desk with led lights, Gaming Desks with LED Lights, Home, LED, Lights, Monitor, Office, Outlets, Port, Power, Room, Stand, USB, USB Power Outlets, White, Workstation$349.99$249.99 -
Sale!
Wired Mixed Backlit Anti-Ghosting Gaming Keyboard
$99.99$79.99 Add to cartWired Mixed Backlit Anti-Ghosting Gaming Keyboard
Categories: Electronics, Gaming, Gaming Keyboards Tags: Antighosting, Backlit, Blue, brown, Gaming, Gaming Keyboard, gaming keyboards, gaming keyboards and mouse, Keyboard, Laptop, Switch, Wired, Wired Mixed Backlit Anti-Ghosting Gaming Keyboard, Wired Mixed Backlit Anti-Ghosting Gaming Keyboards, Wired Mixed Backlit Gaming Keyboard$99.99$79.99 -
Sale!
Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
$119.99$59.99 Add to cartWireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
Categories: Electronics, Gaming, Gaming Headsets Tags: 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, ANC, Audio, Bluetooth, Cancellation, Ear, Earphone, gaming headset, Headphones, Headset, Hi-Res Over the Ear Headphones Headset, HiRes, Noise, Wireless, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Headphones, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headsets$119.99$59.99 -
Sale!
Wired Sports Gaming Headset Earbuds with Microphone
$19.99$9.99 Select optionsWired Sports Gaming Headset Earbuds with Microphone
SKU: N/A Categories: Gaming, Gaming Headsets Tags: Accessories, Earbud, Earphone, Earphones, Gaming, gaming headset with microphone, Headphones, Headset, IOS, Microphone, Sports, Wired, Wired Sports Gaming Headset Earbuds, Wired Sports Gaming Headset Earbuds with Microphone, Wired Sports Headset Earbuds$19.99$9.99 -
Sale!
150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
$49.99$29.99 Add to cart150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
Categories: Charging Stations, Electronics Tags: 150W, 150W Charging Station, 150W Universal Multi USB Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Stations, 150W Universal Multi USB MAX Charging Station, 16 Port MAX Charging Station, 3.5A, Charger, Charging, Fast, laptop charging stations, Max, Multi, Port, Stand, Station, Universal, USB$49.99$29.99
Any recommendations for someone trying to learn on their android phone for use on their android phone?
My school recommended this video ! I finally went through and coded with you and now I feel like I have way more of a grasp instead of constantly referencing the book lol
Scanner?
A big Thank you! ❤
You're the best, do more videos 🙏 Do you also know Android and/or Spring Boot?
watching this at 2x speed. it’s funny that way
took me 46 seconds to fall
17:58 this is the moment where every thing clicked for me. I’ve been learning coding since the beginning of the year(B.S. Software Engineering) , I’ve just now started to watch YT videos on it( Trying to learn without outside help, I regret that) and before now I’ve couldn’t “Think” like a programmer. ITS JUST A BIG FORMULA! I understand now look at it as a formula and not a computer code.
hello blondie,
you explain the code very easy way, I have a combination problem can you solve
Love this, no faffing about, straight to the point. Top banana!
Good summary for java 👌👌
Beginner question here-
Does the indentation matter?
I still don't understand what all this means . You didn't explain .
This video i can see your beautiful face only, not able coding, babe.
Thank you!! It was so much easier to learn from you, bold and concise and straight to the point. Kudos!!!
In 12.5 min.😂
So I followed along, but in the beginning, on the left side of the screen you had a folder named out and when I did everything in the video, it didn't auto create the file named out and I can't make anything appear in the console 🙁
Hmmm! Having a little more freedom here on YouTube ha!
I already have Dreamweaver on my computer, so I guess I can learn java on this platform too, right? It doesn´t necessarily need to run on your suggested platform, or does it?
wow.. so much information. are u trying to get a world records price? couldnt keep up. way, way, way too fast (for beginners)
Boom 💥💥 now we all know Java
Exactly what I needed, THANK YOU SO MUCH!!!💯
wow!slowly lady
I'm still just as confused
This is actually really helpful. This is perfect for people who don't have time to watch those 5 hour-long video tutorials especially when you already have some background knowledge on programming
You covered a lot of things, now java coding makes more sense to me
Terrific!!!!! Quick and easy. Pretty much enjoy it. Thank you very much for publishing this video.
Damn you're good at explaining.
I like that you call it doubly, other devs call double double (same), which creates confusion, like your name was Name.
oh my god wait your telling me Minecraft runs off java whaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatttttttttttttttttt
I just fell in love when she started typing💖