Java Tutorial – 12 – Exploring Java Classes and Packages
![*](https://i0.wp.com/allprowebdesigns.com/wp-content/uploads/2023/12/1703796281_maxresdefault.jpg?resize=840%2C430&ssl=1)
Video Title: Java Tutorial – 12 – Exploring Java Classes and Packages
Hello welcome to mastering Java volume 2 here we’re going to switch gears a little bit in the course up until now we have been rounding out our skills in terms of loops and different types of loops and control structures in Java and those very important stuff we’ve done a
Lot of examples to get you comfortable with having to use the while loops and the do-while loops and the for loops and the if statements and all that stuff but now I really want to change the direction of the latter half of this course a little bit and what we’re going
To do here is start to talk about a little bit about the class structure of Java and then in the last part of the course we’re going to learn how to use a lot of them built in math functions in Java a lot of times you’re trying to
Calculate something and there’s always a lot of times a very easy way to do it using the built in math functions of Java so before we get there I want to show you how to how to look up more detailed Java information about classes now and now we haven’t talked much about
Classes yet in detail but I’m kind of inching my way into it I think I’ve covered up until now drilled it in that Java is just chock-full of a class structure and I’m gonna reveal a little bit of the richness of that class structure right now and then in later
Sections when we talk about classes in detail you’ll understand even more how its structure so right now here’s a web browser if you go to this web address Doc’s dot oracle.com Java SE / 7 / doc / API the seven here means this is Java version seven that’s what’s current as
Of the time of this particular course API stands for application programming interface and so basically it’s a bunch of documentation about how Java is structured so when you and hit enter there you’re taking you’re taken to a page that looks something like this she says Java platform standard edition
Number seven now if you’re watching this course two or three years from now we might be on Java 8 or Java 9 but the core fundamentals of the the structure of Java is really not going to gonna change I mean it has to kind of remain consistent from version to version they
May add functionality but certainly everything we talk about in this section is going to remain the same so the reason we don’t show you this stuff in the beginning of a course is because it’s extremely detailed look at all the stuff you can do your eyes can cross when
You’re when you’re starting to look at this and and when you don’t know anything at all about Java it’s completely overwhelming to start looking at stuff like this but now we know a little bit we’ve done a little bit of programming and so now I think it’s
Instructive to go and talk about that so in the left-hand pane we have what we call packages these are the java packages and if you remember we were importing some packages with the import keyword in a few examples and I’ll get to that in just a minute but anyway
Here’s a list of packages and here’s a listing of all the classes in Java and you can see lots and lots and lots of different classes lots and lots and lots of different packages we’re not gonna cover all this stuff what I want to show you is a couple of very specific things
If you scroll down here you’ll find a Java package called Java dot Lang that means Java dot language that is the fundamental Java package that’s always available to you to use in your programs even without importing anything in other words is the java dot language package consists of a bunch of classes and
Supporting supporting features that are always available anytime you write Java you don’t have to specifically import anything there so let’s click on Java dot Lang and see if we recognize anything so once we click it the only thing that changes is down here now it says Java dot Lang we have something
Called interfaces we have something called classes now again I know that we haven’t discussed a lot of details about what a class is we’re going to get into that a lot more later but you can think of a class as a template it’s it’s when you basically are defining a template
For how something is going to work so you can see in Java we have templates that define what boolean look like we’ve talked about boolean data types we’ve talked about characters and so on there’s floats down here there’s integers down here and so on so these
Are the classes that are wrapped up into this java.lang package and all of these classes are always accessible to anybody writing a Java program you don’t have to import anything extra if you’re going to use any other methods or classes in any of these other packages here then you
Need to import it using the import keyword and if you remember back when we were using the scanner class we had to actually put an import keyword before we could use it so that’s why we had to do that we’ll get to that a little bit more so let’s go and click on
Java dot line again there’s you can you can thumb through here and kind of read a lot of stuff but what I want to show you is the system class there is a system class inside of the java dot lang package and you can see we’re looking
Under classes so if we go to system remember when we try to print something to the screen we do system dot out dot println so what we’re gonna click on a system here and this is a class called system and then there are methods see their methods here that are a member of
This class so everything’s like a tree at the top you have the packages which are collections of things and then you have the classes which are sort of templates for how things are gonna work and then under that you have methods which are these subroutines if you’ve
Used any other language you can you can see that there’s lots of different subroutines that work yet you have something that runs something called a garbage collector you have something that returns an unmodifiable string map view of the current system environment and all these things are not gonna make
Sense until you really have a need to drill down and figure out and use some of these detailed methods but there are thousands and thousands of methods that are available in all of these different classes now which method have we used the most we’ve used system dot out dot
Print Ln so we could scroll down this page and figure out which method is the println method or we can just drop this guy and go to find on this page I’ve already typed in println so it’s going to hit down and you can see that on this
Page we have an in and we have it out because remember we can also do system dot in and we can also do system dot out you can see some information related to how this thing works and I don’t expect you to understand all that but I’m
Trying to show you where the information is so that as you learn more about Java you can come back to this and and understand and learn more about it it tells you that print stream out is the standard output stream the stream is already open ready to accept output data
Typically the stream corresponds to the display or another output destination specified by the host environment or user in other words if you’re using a regular computers in system dot out dot println is going to output stuff the screen is what it’s trying to tell you and it gives you a little example
Here and then it tells us that there that there’s even more information it says see also print stream dot println print stream dot println boolean print stream println care prints dream dot println and so on if you remember the println method we can print integers in
There we can print floats we can print characters we can print regular texts in quotation marks we can string these things together with the plus sign so it’s a very versatile function that can handle lots of different data and put it to the screen and this is showing you
The richness of the println function telling you that really there are sort of different different ways in which it handles the data for instance if we click on the one that says println parentheses int that means integer we click that then it’s telling you its println but it’s accepting as an argument an
Integer and it says it prints an integer and then terminates the line this method behaves as though it invokes print with an integer and then println which means you get a new line you have something similar for long variables all right which are decimal points right so it
Behaves as though it invokes printing a long variable and printing a blank line and then we have something for floats we have something for doubles and so on so you see a lot of this stuff is transparent when you’re using println you don’t have to worry about this stuff
But behind the scenes the creators of java have created the interfaces for the println function to understand how to print integers to the screen and to understand how to print longs to the screen and to understand how to print floats and doubles and we could go down
Here and look at all different ways in which later we’ll talk about strings how the print Ilyn function handles strings all of that stuff has to be defined by somebody and it’s defined by the creators of Java and so all of this stuff is behind the scenes in the java
Dot Lang package which is a subset that would be the system class and then we have the print stream and then the println method down here so I’m not expecting you to get anything more out of this other than just understanding the richness of some of these common and
Sort of easy to use functions and methods and the detailed information that you can go and get to on the Oracle website here all right now we said that this was the java dot lang package we didn’t have to import anything we can always use a print and lin function because this
Package is always available all of these classes are always available if you click on any one of them you’ll see lots of methods and you know things that you don’t quite understand yet because we haven’t talked about constructors but there’s methods here that deal with this
This a known class here and there those are things that are always available because they’re inside the java dot Lang package so you can kind of think of them as being the most important or the most commonly used methods and functions inside of Java but let’s go to something
That isn’t quite so common remember we use the scanner class and when we did that we had to type in import Java dot util right so Java dot util remember we had to do that so let’s click on that and when we go down here we had to type
In import Java dot util dot scanner if we go down and look in the classes that are a part of this package if we go down to the esses down here we see a scanner class so this is giving you a listing of all of the different classes that are
Part of the Java dot util package if we click on scanner it tells us it’s a class called scanner it tells us that we import it like this Java dot util dot scanner right and then it tells us some information it says for example well actually we can read this here a scanner
Breaks its input into tokens using delimiter pattern which by default matches whitespace resulting tokens make can be converted to different data types so that’s what the way that scanner can read at integers and floats and other things we’ve kind of done that before and then it gives a little bit of
Example code we define a scanner object new scanner system done in we’ve been doing that all of our programs and then we go and take an integer and assign it to the next integer available at the scanner there so you can get some example code you can read about
Different input/output cases there’s a lot information here a lot more than we have ever had to use in any of our any of our programs but if you look here here’s hasnext integer this is what we’ve used for to figure out if there’s another integer waiting for you has next float
This is what we figured out it says returns true if the next token in the scanners input can be interpreted as a float using the next float method so we’ve used a lot of this stuff but I’m trying to show you where a lot of this information comes from if you need to
Look up a class the best bet my opinion is to jump onto the Oracle website go down here and then you can click on any of these things and start to see examples of how it’s done what it takes is an input what it does is an output
And so on so that is an overview of how to use the website there are far too many things here to go into detail over but I wanted to show you the classes I wanted to show you the basic packages and sort of how to navigate now what I
Want to do is go back to the java dot Lang package and show you a very important class under classes we will look at the math class right look at the math class because we’re going to be doing a lot with that here in the next
Few lessons and the math class if you scroll down methods summary all right here all the methods that are a part of the math class so ABS returns the absolute value of a double value this is just like in math class when you take the absolute value of something we have
Arc cosine to return the inverse cosine of a number we can scroll down here and we can see we can do floor which is kind of like rounding we can do what else do we have down here square root here’s an important one square root we can pass a
Double value which is a decimal value and then form of a double variable to the square root method and it’s going to return the positive square root value of that number we have hyperbolic functions we have tons of functions in here we’re gonna go through these and understand a lot of
Them because they’re important to you to learn how to use the basic math functions inside Java but what I want to do is that as we go through the next few lessons and learn about the math functions of Java just remember that you can come here and you can always learn
About how to use any of these for instance if I wanted to learn how to use a logarithm right I could just click on this method called log which is a member of the math class and then it’ll tell you it returns the natural logarithm base fee of the double value and it
Gives you some special cases and so on but the bottom lines that gives you a basic idea about how to use that particular method so this Web it’s very very important here’s your packages here’s the classes and then you can get information about the classes how to use them basically how
Everything’s organized you can go in and poke around here and start learning about all the richness of Java we’re not going to use a lot of this in the short term except for the math functions we will be using pretty soon but I wanted you to understand where you can go for
More detailed information because as you learn more about Java as you learn and look at example code on the web or maybe in a class or something and you’re you know an exam or something you may have a need to go and look that class up and my
Opinion the easiest way to do that is right here on this website
-
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
Love this but why did you say Long variables involve decimal points? I though Longs were very large whole numbers (or numbers that are really long).
I am glad to be your student , perfect explanation
your explanation and English are so clear and understandable great work
please make more videos on other programming language. Your explanations are clear and the way you deliver your notes in different videos is so perfect. Thanks
Your explanations are crystal clear. Thanks for your videos!