Lesson 2 of 34

Variables மற்றும் Data Types

8 min 20 XP

Java-ல் ஒரு variable உருவாக்கும்போது அதன் type-ஐ முதலில் சொல்ல வேண்டும். int முழு எண்களுக்கு, double தசம எண்களுக்கு, boolean true/false-க்கு, char ஒரு எழுத்துக்கு, String text-க்கு.

Example: edit me and press Run

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

String-உடன் + சேர்த்தால் அவை ஒன்றாக இணையும் (concatenation). Variable-ன் மதிப்பை பின்னர் மாற்றலாம், ஆனால் 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.

final என்று போட்டால் அந்த variable-ஐ மீண்டும் மாற்ற முடியாது (constant). Constant பெயர்களை CAPITAL எழுத்துகளில் எழுதுவது வழக்கம்.

Challenge

+20 XP

city என்ற String variable-ல் "Erode", year என்ற int variable-ல் 2026 சேமித்து இப்படி print செய்யுங்கள்: City: Erode Year: 2026

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