To answer the questions about the string.format error, I used a fix someone mentioned in a previous video. Go to project up at the top, properties, java compiler, uncheck the "use compliance from exe environment" box, and change compiler comp lvl to something like 1.7. Worked for me, hope this is helpful to some!
Your tutorials are so great that i spent appx 4 hours watching today and did not realise its 36th tutorial now. OMG! I am already an array expert which took me appx 2 weeks in C when i started. Thanks Bucky.
I like the style that hes checking the input straight away in the setMethod in short form with the conditional operator, that saves lot of time and writing - traditionally that is often done with a side check method what can become really cluttered in the end - great videos - keep em up!
Bucky! Thanks a lot mate. You've done a whole lot of work. I'm sure you love doing this else you wont have put this amount of time in doing all this for us. I've learned a lot more from your tutorials than I learn from my Bachelor's degree lectures. Seriously, I should consider dropping out of college like you did and learning online! You are my inspiration for this LOL :P :D
Rowan Belt well the value would need over 10 digits to round to 10 significant figures. If it’s above 99 it will round to that amount of figures, but only if it has more than that. 345 rounded to 2sf is 350 The same would happen if you found to 200sf, but the number would need an extra 200 digits
I really like your tutorials, they're easy etc (Just about everything the others have said). In this tutorial, I added Scanner also (Got the hang on it from your Tutorial 26), so I can type my own numbers in without modifying the code.
I don't remember if he explained either, but to clear up confusion: the bit in the quotes is the format of how the String is displayed on return. %02d means "display the variable as a 2 digit number with a 0 padding on the left side, so 1 becomes 01", etc. The % is the variable. The :'s were just formatting and to separate the numbers.
An example of return: public static int halfNumber(int x){ double y; y = x/2; return y; } This method halves the number you input and returns the halved number. So if you say num = 10; and then write halfednum = halfNumber(num); , then the variable halfednum will contain 5.0 because the method halfNumber RETURNED 5.0 and put it into the variable halfednum. Any method with "void" in the header has no return statement within.
An example, btw this has to be in the same class as the main method OUTSIDE the main method public static int CoD() { int PWN = 360; return PWN; } public static void main(String[] args) { System.out.println(method()); } this will display "360" because "CoD()" is equal to 360 because its method returns PWN which has a value of 360.
@Zorobay You are creating an object (or instance) of the class tuna, and you call the method from that object. His object name was tunaObject and so you have to call that. You can only call static methods directly from the class.
@SargentSpecs I don't know why he put the "02" in there, but he put the "%d" in there because it's a placeholder for a digit. For example, ("%d, %d", hour, second) would return the hour and second that you had set using setTime(int h, int m, int s)
there is a program call "always on top" google it, its the first search result, it runs a script and your window will always be on top of other applications :D
It's a java function to display characters in a more controlled way than System.out.println(). The percentage is a escape character (so he doesn't print "02d" straight away). The "d" tells the funciotn it's going to print digits, the 2 tells that the number occupies 2 algarisms (for example, "7" is " 7") and the "0" tells to fill the blanks with 0 (so " 7" becomes "07").
You know you are good at what you do bro, 'programming'. I'd appreciate it if you give us a challenege or a homework sort of thing to do...not small but bit longer program to make just as a revision for us...I'm struggling in programing class mate i'm bout to fail.
the method takes in input, goes to the tuna class ,does some function to and then the RETURN takes the new value back to the apples class, were the method was called, so you can do whatever you want with it such as add, divide, add to array etc
Everytime I try to type something and format the output, I get this mistake: The method format(String, Object[]) in the type String is not applicable for the arguments (String, int, int, int). My code is exactly the same thing as his. public String toMilitary(){ return String.format("%02d:%02d:%02d", getHour(),getMinute(),getSecond()); }
@MisterM2402 It isn't static because it doesn't need to be, the "tuna" class will handle the function therefore it can be called from within the "static" main method as it is not within the same class. The only reason static is required within the main class (the one with the main function) is because there isn't an instance of this class to handle them, therefore they need to be static to be used.
People listen to me. In your Tuna class go to the line of code with the return type for the method toMilitary(). Replace all the "O" with zeros "0". Your code should run just fine as long as everything else is correct.
@DogDino Makes sense... Notch learns Java from Bucky. Notch creates Minecraft which sparks widespread interest in Java. As a result, more people go to Bucky to learn Java so they can make games (which will spark even more interest in Java). It's like an infinite loop in real life.
@EchoSnipinn the code i wrote is still valid and it works... the military/army/not normal people say 12 hundred hours and so forth, but they also say 24hundred hours as well... with bucky's code it only does up to 23 hundred hours...
@Favorlock well those tutorials are still for beginner stuff....he is just teaching you the basic keywords and how to get familiar with java...advanced tutorials are on the way don't worry :)
@Hapistorique I think that it means to display a 0, then display '2' = second, decimal(Colon). So it comes out 0:00. Sorry if I just confused you, I'm not that good at explaining stuff.
I have no idea why he uses String.format, what is that supposed to mean? I know that method returns a string which is the one in between brackets, it is the "format" word that buggs me, he never declared that
Hello. You see, String is a class in Java and as a class, it has its own built in methods that it call. So the format is a method that belongs to the String class. you can tell this by the "." between String and format which means "String calls the format method" To answer your question, the String.format allows for a specific output that you want. Hence allowing you design it to you liking.
for statements like, ? m : 0 it might be better make it like, ? m : -999 Just so the user doesn't unknowingly input something incorrectly. Thanks for the tutorials, they're great!!
For everyone that gets error Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'O' at java.util.Formatter$FormatSpecifier.conversion(Unknown Source) at java.util.Formatter$FormatSpecifier.(Unknown Source) at java.util.Formatter.parse(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.lang.String.format(Unknown Source) at tuna.toMilitary(tuna.java:42) at apples.main(apples.java:10) in string.format use 0 (number) instead of O (letter) and check the rest of "%02d [...]" you need to have exactly the same code
He could have done... return Integer.toString((hour + ":" + minute + ":" + second)) But it is clunky. hour, min, sec are ints which cannot be return as a String unless converted. String.format is one way to convert a integer to a string, Integer.toString is another way of doing so.
I have been following these tutorials awhile to begin my introduction into the Java programming language but this episode raised some questions I've been thinking about. How come with the return for the toMilitary String is the the fortmat, "%02d", why is it decimals, how come you just cant set it to print out its value? Also what exactly does the period inbetween different displays and such do exactly, is it used to set things or to access them?
I was just about to ask "when does he actually explain what all this 'static' nonsense is?!" - in the related videos, tutorial 47. Can't wait! :D (I just wanna know why setTime isn't "static").
guys i figured it use if else statement like if hour = 24 && hour =0 h = hour else h = 0 sorry couldn't paste the code stupid you tube doesn't allow html tags thanks bucky your tutorials helped me figure out the error :D
I'm gettin an error in toMilitary method: The method format(String, Object[]) in the type String is not applicable for the arguments (String, int, int, int)
@ZachR0 hey since you seem to be a very good programmer could you tell me this am I making the right decision learning java? the reason i'm trying to learn it is because i want to program some simple games is c++ better for that sort of programing or should i stick with java? and also is it possible to make a 3d game engine in java? please answer if you want ;) thanks in advance
@MrStropwen Well a string is things like numbers and words that have no real value. for example if you wanted to program that printed HelloWorld you would put System.out.print("HelloWorld") HelloWorld is a string but if you put System.out.print(HelloWorld) that is not a string instead it is a variable that should point to something. but since HelloWorld has no value it should not return anything but an error.so in short "hi" is not the same as hi unless hi had a value of "hi"
@canadia7x he put the "02" as a placeholder for two places so if you put hour as 5 with the "%02d" it shows up as "05" or if you only put "%d" it will show up as "5"
great videos but what is the general format of this advanced if test that he is using to check if the hour, minute and seconds lies in their normal ranges. have he explained that before? thanks
Hey shouldve mentioned conditional statements could be used in assignment statements. Now Im all confused. Where else can they be used? Method parameters? Anything else?
You are wrong - it is not going to be in another thread unless you tell it to be. He is doing it to familiarize you with working with multiple classes because this is how you do it.(it is easier do read the code)
I think this would be more useful in the setTime method: hour = (h%24 + m/60 + s/3600); mintute = (m%60 + s/60); second = (s%60); thus allowing the user to enter for example 3749 seconds and have that converted.
to make a bit more fun and challenging write a code to as the user to input hour, min, secs then output it as to military. to make it even more challenging as user to put in hour 1-12 then have them choose between pm or AM and check it with a if statement then output in military
@kibaszottkurvajutub the toMilitary() method in this video is just one he created. He could have called it anything. If I understood your question right you probably already figured it out. Hope that makes sense
Finally, the tuna class not being used for so long was bothering me :P
zoranhacker 哈哈哈哈哈哈哈
trans. hahahahahahaha
turns on computer gets on youtube "okay im going to watch programming videos for a few minutes" 3 hours later looks up at clock "dang it"
damn it is true lol
STFU
You can't beat Bucky's commentary
Yeah :)
To answer the questions about the string.format error, I used a fix someone mentioned in a previous video. Go to project up at the top, properties, java compiler, uncheck the "use compliance from exe environment" box, and change compiler comp lvl to something like 1.7. Worked for me, hope this is helpful to some!
thanks man!
+Kyle B thank you very, very, veryyyyyyyyy much :)
+Kyle B You Are Awesome, thanks.....
thank you very much
Do you know why this works?
Your tutorials are so great that i spent appx 4 hours watching today and did not realise its 36th tutorial now. OMG! I am already an array expert which took me appx 2 weeks in C when i started.
Thanks Bucky.
thanks a lot. more importantly ur voice doesnt make me sleepy like others :)
again please keep in mine the ads only pay if they are watched so help this good man and watch the ads :)
or install Adblock as well!!
right
@@ajay000003 🤣🤣🤣🤣🤣🤣🤣 adblock can't block ads from RUclips a.....
@@youricadet1557 yes it can ma nigga
@@youricadet1557 youtube adblock does, I have it and I never get ads
Your videos are so easy to understand. In one day I've watched 36 videos and I am ahead of all my class now. Thanks a lot!!
I like the style that hes checking the input straight away in the setMethod in short form with the conditional operator, that saves lot of time and writing - traditionally that is often done with a side check method what can become really cluttered in the end - great videos - keep em up!
I'm grateful that I'm learning so much without getting a sense of stopping and leaving this. This is probably the first time ! Thanks Bucky! :D
"Well would you look at that" XD
kind, but not kind enough.
Jay Bartgis he's annoyed with his Screen recorder :D
I've started taking notes for every video. Just a tip so you're not lost in the future.
maybe it indicates that i'm a nerd, but Bucky cracks me up in these tutorials. lol
Bucky! Thanks a lot mate. You've done a whole lot of work. I'm sure you love doing this else you wont have put this amount of time in doing all this for us. I've learned a lot more from your tutorials than I learn from my Bachelor's degree lectures. Seriously, I should consider dropping out of college like you did and learning online!
You are my inspiration for this LOL :P :D
%02d means two digits, not two decimal places. :D
2 sig figs yeah. I got a bit confused when he started talking about decimal places.
i m also confuse wht is role of %02d plz help
%02d gets replaced with corresponding variable. It means 2 digits.
So %10d would mean to 10 digits? And also, if the value is greater than 99 or smaller than 0, what will happen?
Rowan Belt well the value would need over 10 digits to round to 10 significant figures. If it’s above 99 it will round to that amount of figures, but only if it has more than that.
345 rounded to 2sf is 350
The same would happen if you found to 200sf, but the number would need an extra 200 digits
I added in the Scanner to allow user input for entering the hour, minute and seconds Sweet!
Great Tutorials
I really like your tutorials, they're easy etc (Just about everything the others have said). In this tutorial, I added Scanner also (Got the hang on it from your Tutorial 26), so I can type my own numbers in without modifying the code.
Dude you are great currently taking a beginners course in Java in college and you help so much in combination of my book
I don't remember if he explained either, but to clear up confusion: the bit in the quotes is the format of how the String is displayed on return. %02d means "display the variable as a 2 digit number with a 0 padding on the left side, so 1 becomes 01", etc. The % is the variable. The :'s were just formatting and to separate the numbers.
What String.format(arg1, arg2) does? Or in which episode did he mentioned it before?
I wish I knew of your channel before I went upon learning C and C++, you would'a saved me sooo much time and frustration :/
Time to be a Time Lord
Java is about simplicity and organization. It is more efficient to work with objects rather stuffing everything into one class.
your little quirks on this one were soo funny, "kind but not kind enough... why don't you fill in the rest for us?" got me laughing so hard
An example of return:
public static int halfNumber(int x){
double y;
y = x/2;
return y;
}
This method halves the number you input and returns the halved number. So if you say num = 10; and then write halfednum = halfNumber(num); , then the variable halfednum will contain 5.0 because the method halfNumber RETURNED 5.0 and put it into the variable halfednum.
Any method with "void" in the header has no return statement within.
An example, btw this has to be in the same class as the main method OUTSIDE the main method
public static int CoD()
{
int PWN = 360;
return PWN;
}
public static void main(String[] args)
{
System.out.println(method());
}
this will display "360" because "CoD()" is equal to 360 because its method returns PWN which has a value of 360.
i am watching this playlist from December 2023 .. best playlist ever i swear
@35spike2 ooo i see where you get confused, in the code its written h>=0, and 0 is the same as 24, if not you could also do it h>0 && h
2020 is here but it is still a great tutorial, like if agree
For the people who are confused: "%02d" means a decimal value in two digits. You could just use "%d" though..
I would gladly pay for theese videos.
@Zorobay You are creating an object (or instance) of the class tuna, and you call the method from that object. His object name was tunaObject and so you have to call that. You can only call static methods directly from the class.
JESUS WOW, THANK YOU I GOT STUCK ON THAT FOREVER
@SargentSpecs I don't know why he put the "02" in there, but he put the "%d" in there because it's a placeholder for a digit. For example, ("%d, %d", hour, second) would return the hour and second that you had set using setTime(int h, int m, int s)
Thanks for the explanation, finally i understand that part now.
there is a program call "always on top" google it, its the first search result, it runs a script and your window will always be on top of other applications :D
It's a java function to display characters in a more controlled way than System.out.println().
The percentage is a escape character (so he doesn't print "02d" straight away). The "d" tells the funciotn it's going to print digits, the 2 tells that the number occupies 2 algarisms (for example, "7" is " 7") and the "0" tells to fill the blanks with 0 (so " 7" becomes "07").
You are a very good champ. I'm going to name my dog after you. Ty.
You know you are good at what you do bro, 'programming'. I'd appreciate it if you give us a challenege or a homework sort of thing to do...not small but bit longer program to make just as a revision for us...I'm struggling in programing class mate i'm bout to fail.
your tutorials are so good i love thm all think you and keep the good work ...God bless you
Wow thanks bucky, You are an amazing teacher. Thank you.
the method takes in input, goes to the tuna class ,does some function to and then the RETURN takes the new value back to the apples class, were the method was called, so you can do whatever you want with it such as add, divide, add to array etc
This was long long ago, and I am here in 2022 during Class 12!
Everytime I try to type something and format the output, I get this mistake: The method format(String, Object[]) in the type String is not applicable for the arguments (String, int, int, int).
My code is exactly the same thing as his.
public String toMilitary(){
return String.format("%02d:%02d:%02d", getHour(),getMinute(),getSecond());
}
Try this:
public String toMilitary(){
return String.format("%02d:%02d:%02d", hour, minute, second);
}
@Nepnepdrum Try Run as>Run Configuration> Main Class, click search and put the class where u're working now.
@Hapistorique it means you get 2 spaces for each unit of time, for example 12:34:13 (there are 2 spaces between each colon)
Really good tutorials, have helped me a lot!
@MisterM2402 It isn't static because it doesn't need to be, the "tuna" class will handle the function therefore it can be called from within the "static" main method as it is not within the same class. The only reason static is required within the main class (the one with the main function) is because there isn't an instance of this class to handle them, therefore they need to be static to be used.
People listen to me. In your Tuna class go to the line of code with the return type for the method toMilitary(). Replace all the "O" with zeros "0". Your code should run just fine as long as everything else is correct.
2:01 check it out...hahahahahahahaha priceless
@DogDino Makes sense... Notch learns Java from Bucky. Notch creates Minecraft which sparks widespread interest in Java. As a result, more people go to Bucky to learn Java so they can make games (which will spark even more interest in Java).
It's like an infinite loop in real life.
may god reward you bucky
@EchoSnipinn the code i wrote is still valid and it works...
the military/army/not normal people say 12 hundred hours and so forth, but they also say 24hundred hours as well...
with bucky's code it only does up to 23 hundred hours...
@Favorlock well those tutorials are still for beginner stuff....he is just teaching you the basic keywords and how to get familiar with java...advanced tutorials are on the way don't worry :)
@Hapistorique I think that it means to display a 0, then display '2' = second, decimal(Colon). So it comes out 0:00. Sorry if I just confused you, I'm not that good at explaining stuff.
copying can lines can be faster in eclipse, use the shortcut CTRL + Alt + Down key on the line you wish to copy
excellent tutorial... you make java so easy!! thank youuu...
you my friend, are a genius
just write sysout in eclipse hit cntl+enter automatically System.out.println() pops up..
ctrl + space for me... :/
it doesn't work for me
ctrl + space
For IntelliJ IDEA "sout" and than press ENTER
man need some help can you tell me how to use (return String.format) in java 8. whenever i write return String.format() in gives error .plzzz help
"What is learned as a child, is mastered as an old person."
Bucky you messed up :/
"hour = ((h >= 0 && h
What's 0 then?
I think they use 0 as midnight, at lease in EU we do that
@@giuliopimenoff yes bro, you are right, there is 0 for 12 =. I am using 0 for 12 night
Did he say "After Effects" ?? Wow i love this guy>
The green bar was there because eclipse auto changed something. The green bars show what it changes.
I have no idea why he uses String.format, what is that supposed to mean? I know that method returns a string which is the one in between brackets, it is the "format" word that buggs me, he never declared that
Pleeeeeeeeeeease someone help
Hello.
You see, String is a class in Java and as a class, it has its own built in methods that it call. So the format is a method that belongs to the String class. you can tell this by the "." between String and format which means "String calls the format method"
To answer your question, the String.format allows for a specific output that you want. Hence allowing you design it to you liking.
or make the method void and just use printf :)
when did you explain format
NEVER
@@Rahulbajaj561 It has been very long since u took a shower xD
man your de best tutor ever
Thanks alot ;-)
3:15 OMG! HE DOES KNOW WHAT CONTROL + V DOES :D
That's not ctrl + v
for statements like, ? m : 0
it might be better make it like, ? m : -999
Just so the user doesn't unknowingly input something incorrectly.
Thanks for the tutorials, they're great!!
@matthewdoucette No, he used the less than symbol, meaning, if you put in 24 it would use 0, use 24 is not less than 24. (Same for m and s.)
For everyone that gets error Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'O'
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at tuna.toMilitary(tuna.java:42)
at apples.main(apples.java:10)
in string.format use 0 (number) instead of O (letter) and check the rest of "%02d [...]" you need to have exactly the same code
It works. Thanks!
Awesome! Thank you
May you be blessed, thank you! It worked!
ÄssäHai Bless bublgmm
thanks!
what is String.format( )
is used for..?
anyone..? bucky...?
He could have done...
return Integer.toString((hour + ":" + minute + ":" + second))
But it is clunky.
hour, min, sec are ints which cannot be return as a String unless converted.
String.format is one way to convert a integer to a string, Integer.toString is another way of doing so.
+videoVulcan Thanks a lot ..That really helped..
I have been following these tutorials awhile to begin my introduction into the Java programming language but this episode raised some questions I've been thinking about. How come with the return for the toMilitary String is the the fortmat, "%02d", why is it decimals, how come you just cant set it to print out its value?
Also what exactly does the period inbetween different displays and such do exactly, is it used to set things or to access them?
My streamer was learning java Pog
I was just about to ask "when does he actually explain what all this 'static' nonsense is?!" - in the related videos, tutorial 47. Can't wait! :D (I just wanna know why setTime isn't "static").
What is the necessity of declaring private variables instead of public ones in the Tuna class?
guys i figured it use if else statement like if hour = 24 && hour =0 h = hour else h = 0 sorry couldn't paste the code stupid you tube doesn't allow html tags thanks bucky your tutorials helped me figure out the error :D
look at the first few tutorials and then add it in yourself - its very simple.
I'm gettin an error in toMilitary method: The method format(String, Object[]) in the type String is not applicable for the arguments (String, int, int, int)
+bikesh shakya
can you copy your tuna class here?
Why are the variables declared private? Couldn't the program work with public variables?
"kind ,but not kind enough"
the farther i watch his tutorial the more complex it becomes I sometimes confuse myself into these
Finally... Arrays Were Getting Quite Boring
agreed
why is the second method in tuna class (toMilitary) a string if its returning numbers? I dont get it please enlighten me
@ZachR0 hey since you seem to be a very good programmer could you tell me this
am I making the right decision learning java?
the reason i'm trying to learn it is because i want to program some simple games
is c++ better for that sort of programing or should i stick with java?
and also is it possible to make a 3d game engine in java?
please answer if you want ;)
thanks in advance
@MrStropwen Well a string is things like numbers and words that have no real value.
for example if you wanted to program that printed HelloWorld you would put
System.out.print("HelloWorld") HelloWorld is a string but if you put
System.out.print(HelloWorld) that is not a string instead it is a variable that should point to something. but since HelloWorld has no value it should not return anything but an error.so in short "hi" is not the same as hi unless hi had a value of "hi"
@canadia7x
he put the "02" as a placeholder for two places so if you put hour as 5 with the "%02d" it shows up as "05" or if you only put "%d" it will show up as "5"
what are the conditions of writing the word "static"
+Ramy Tawfik ??
great videos
but what is the general format of this advanced if test that he is using to check if the hour, minute and seconds lies in their normal ranges. have he explained that before?
thanks
Hey shouldve mentioned conditional statements could be used in assignment statements. Now Im all confused. Where else can they be used? Method parameters? Anything else?
You are wrong - it is not going to be in another thread unless you tell it to be. He is doing it to familiarize you with working with multiple classes because this is how you do it.(it is easier do read the code)
I think this would be more useful in the setTime method:
hour = (h%24 + m/60 + s/3600);
mintute = (m%60 + s/60);
second = (s%60);
thus allowing the user to enter for example 3749 seconds and have that converted.
ATTENTION!!!!!! THE o2d is not with the letter o but with 0(zero).
hey bucky.... by any chance you have Tutorials for Advanced Java ie for Java Collections???
i like instructions that constantly remind me to be lazy
@MrStropwen its not a variable -_-, its a string, its just letters that you can print out in the command line
to make a bit more fun and challenging write a code to as the user to input hour, min, secs then output it as to military. to make it even more challenging as user to put in hour 1-12 then have them choose between pm or AM and check it with a if statement then output in military
@kibaszottkurvajutub the toMilitary() method in this video is just one he created. He could have called it anything. If I understood your question right you probably already figured it out. Hope that makes sense
You can do it your way too. Also there is no such thing as 0 hour, 0 min, 0 second so why is it >=? Shouldnt it be just (h>0 && h
it was easy to understand thx alot!
love the tutorial! Thank you!
@tonilocoable yes but some people might not know that so therefor its good that he points it out...
2013, still extremely helpful :)