println और print
println स्क्रीन पर कुछ दिखाता है और अगली line पर चला जाता है, जबकि print उसी line पर रहता है। यह एक वाक्य बोलने और या तो enter दबाने या जारी रखने जैसा है।
In this page:
Syntax
println(value)
print(value)
println and print
println एक value को newline के साथ print करता है, जबकि print बिना newline जोड़े print करता है। दोनों किसी भी value को accept करते हैं और उस पर implicit रूप से .toString call करते हैं।
println, दोनों में से कहीं ज़्यादा उपयोग होता है, क्योंकि ज़्यादातर output अपनी ही line पर खत्म होने से फायदा पाता है।
Note:
formatted output बनाने के सबसे साफ़, सबसे readable तरीके के लिए
println के साथ string interpolation (s"...") का उपयोग करें।उदाहरण: println and print
object Main extends App {
println("This line ends with a newline")
print("This line ")
print("does not, so ")
println("this continues on the same line")
}
Login to try C/C++/Java/PHP code in the editor
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
printका उपयोग करना और पूरा output एक ही line पर पाना क्योंकि यह newline नहीं जोड़ता।println("a", "b")जैसी कई values पास करना, जो दो values की बजाय एक tuple(a,b)print करता है।- यह उम्मीद करना कि
printlnnumbers को format करेगा, जैसेprintln(3.10)का3.1print करना, जबकि fixed decimals के लिए आपकोf"..."चाहिए।
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: