Lesson 2 of 34

Variables आणि Data Types

8 min 20 XP

Java मध्ये variable तयार करताना त्याचा type सांगावा लागतो. int पूर्ण संख्यांसाठी, double दशांशांसाठी, boolean true/false साठी, char एका अक्षरासाठी आणि String मजकुरासाठी.

Example: edit me and press Run

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

String सोबत + वापरल्यास values जोडल्या जातात (concatenation). Variable ची value नंतर बदलता येते, पण type नाही. char ला single quotes ' ', String ला double quotes " ".

Example: edit me and press Run

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

Variable ला final केले की ते कधीच बदलत नाही (constant). Constants ची नावे सहसा CAPITALS मध्ये लिहितात.

Challenge

+20 XP

String variable city मध्ये "Erode" आणि int variable year मध्ये 2026 ठेवा, मग print करा: City: Erode Year: 2026

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