Need help with printf | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Need help with printf

i cannot figure out printf what can i do with it and how do i make use of it and how do i best use it? can someone explain it in simply so that my noob self can understand?

31st Mar 2017, 8:12 AM
flamethekid
flamethekid - avatar
9 Answers
+ 18
Are you familiar with printf() of C? Then it'll be easy for you to understand how the placeholders work. int num = 4; char letter = 'A'; double value = 5.8; System.out.printf("%d %c %.2f", num, letter, value); // output : 4 A 5.80
31st Mar 2017, 8:26 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 18
@very hard .... ... ~\(≧▽≦)/~~\(≧▽≦)/~ Typing "Master" is easier and less time consuming than typing your actual name 😈
31st Mar 2017, 8:38 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 8
https://code.sololearn.com/cXX20M0x1PA4/?ref=app this is some short stuff that I can explain to you about String.format Don't call me master. I hate it (I'm noob!)
31st Mar 2017, 8:27 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 8
@Shamima Yasmin -_____- Don't mention about my name
31st Mar 2017, 8:40 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 6
Ah..... I never use printf in java I use String.format() Instead
31st Mar 2017, 8:15 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
thank you guys alot for the explanation
31st Mar 2017, 5:25 PM
flamethekid
flamethekid - avatar
+ 1
bout to read that how does String.format work? teach me master 😢
31st Mar 2017, 8:17 AM
flamethekid
flamethekid - avatar
0
It's a regular print function you can use in order to print strings. Try to learn all of those functions because you are going to need them in order to code better. Otherwise it might affect you with errors which spend a lot of precious time. Of course you can always use an app to detect those errors for you. I have heard of one called checkmarx you can try. Anyway, good luck! Ben.
31st Mar 2017, 2:27 PM
Ben hart