0

DATA TYPES:

Question: How to format any assigned value in java like we do in python like this===> Anu="Anurag" print(f"My name is {Anu}") How we do it in java

19th Jan 2021, 11:30 AM
Anurag Kumar
Anurag Kumar - avatar
7 Answers
+ 2
šŸŒŸĪ±nurĪ±g kumĪ±ršŸŒŸ you have to try it yourself to find out.
19th Jan 2021, 2:30 PM
Arsenic
Arsenic - avatar
+ 1
šŸŒŸĪ±nurĪ±g kumĪ±ršŸŒŸ Just do concatenation System.out.println("My name is " + Anu);
19th Jan 2021, 11:45 AM
AĶ¢J
AĶ¢J - avatar
+ 1
Apart from what the others have said, if you don't like concatenation, you can use the System.out.printf function for formatted strings. It is like doing `"My name is %s" % Anu` in Python https://docs.oracle.com/javase/tutorial/java/data/numberformat.html
19th Jan 2021, 2:37 PM
XXX
XXX - avatar
0
It will return me result
19th Jan 2021, 11:48 AM
Anurag Kumar
Anurag Kumar - avatar
0
šŸŒŸĪ±nurĪ±g kumĪ±ršŸŒŸ Yes just try in Code Playground
19th Jan 2021, 2:42 PM
AĶ¢J
AĶ¢J - avatar
0
Ok thanks very much : )
20th Jan 2021, 5:05 AM
Anurag Kumar
Anurag Kumar - avatar
0
String.format() is like .format python
21st Jan 2021, 1:36 AM
David OrdƔs
David OrdƔs - avatar