Skip to content

Chamupathi Gigara's personal Blog

Just another Giga Network site

Menu
  • Blog
  • About Me
Menu

Java – Variables

Posted on July 1, 2018July 1, 2018 by gigara

වැඩසටහන් වලදී අපට විවිධ දත්ත ගබඩාකිිිරීමට අවශ්‍යවනවා. එම දත්ත තාවකාලිකව ගබඩාකර තබා ගැනීම සදහා අප variables භාවිතා කරනු ලබනවා.

Declaration

Variables පවතින්නේ අපි කලින් ලිපියේදී සාකච්ඡා කරපු data types වලිනි.

eg: int giga;
int var;
string name;

මෙහිදී අප ගබඩා කිරීමට බලාපොරොත්තු වන දත්ත වලට අදාලව data type එක තෝරාගත යුතුය.

Initialization

Declare කල variable වලට අගයන් ලබා දීම පහත පරිදි සිදු කෙරේ.

giga = 10;
var = 5;
name = “Chamupathi”;

• Variable එකට අගයක් ලබා දීමට පෙර එය declare කිරීම අනිවාර්යය.

Variable එක declare කරන අවස්ථාවේදීම ද එය initialize කල හැක.

eg: int marks = 33; // int is the type & marks is the name

Variable නම් කිරීමේ සම්මතයන්. Naming Convention for Variables

  • මුල් අකුර simple අකුරක් විය යුතුයි
  • යෙදිම විස්තර විය යුතුය.
    eg: String name; – to store name
    int age; – to store age
  • එක වචනයකට වඩා තිබේ නම් දෙවෙනි වචනයේ මුලකුර capital විය යුතුය.
    eg: int fullName;

Variable නම් කිරීමේ නීති. Rules to Name Variable

  • අකුරකින් , _ සලකුණකින් හෝ $ සලකුණකින් ආරම්භ විය යුතුය.
  • Space තිබිය නොහැක.
  • විශේෂිත වූ අක්ෂර තිබිය නොහැක. ( %, @, !, #, &, ^,…)

Valid names

m
c2c
PI
circle_Area
circleArea2

Invalid names

2m
Xyz!
!2d#d
Circle Area
@@##

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • දේවාරූඩයෙන් Code කරන්න
  • මොනවද මේ Malware?
  • WhatsApp සදහටම නැති වෙයි?
  • Ballerina ගැන සිංහලෙන් – Ballerina in Sinhala
  • VPN ගැන ඔබ දැනුවත් ද?

Recent Comments

  • දේවාරූඩයෙන් Code කරන්න | Chamupathi Gigara's personal Blog on Ballerina ගැන සිංහලෙන් – Ballerina in Sinhala
  • Aruna Danuddara on මොනවද මේ Malware?
  • Nishiki Yapa on මොනවද මේ Malware?
  • Papaya on මොනවද මේ Malware?
  • Vidushika Ruwanpathirana on WhatsApp සදහටම නැති වෙයි?

Archives

  • February 2022
  • April 2020
  • December 2019
  • July 2019
  • April 2019
  • March 2019
  • February 2019
  • July 2018
  • March 2018
  • February 2018

Categories

  • Ballerina
  • Cyber Security
  • Java
  • Python
  • Uncategorized
© 2022 Chamupathi Gigara's personal Blog | Powered by Superbs Personal Blog theme