Lesson 3 of 34

Scanner ने Input वाचणे

8 min 20 XP

वापरकर्त्याकडून values आपण Scanner ने वाचतो. आधी सर्वात वर import java.util.Scanner; लिहा. Run दाबण्यापूर्वी values Input box मध्ये टाइप करा.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

nextInt() पूर्ण संख्या वाचते, nextDouble() दशांश, next() एक शब्द (space पर्यंत) आणि nextLine() संपूर्ण ओळ. Spaces किंवा नवीन ओळींनी वेगळ्या केलेल्या values एकेक करून वाचल्या जातात.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

"Sum = " + a + b लिहिल्यास 1230 print होते! संख्या आधी जोडल्या जाव्यात म्हणून (a + b) brackets मध्ये ठेवा.

Challenge

+20 XP

दोन पूर्ण संख्या वाचा आणि त्यांचा गुणाकार print करा. Input: 6 7 → Output: 42

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.