<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>abstract class &#8211; The SIGMA</title>
	<atom:link href="https://danushka96.github.io/sigma/index.php/tag/abstract-class/feed/" rel="self" type="application/rss+xml" />
	<link>https://danushka96.github.io/sigma/</link>
	<description>&#60;For Those Who Code/&#62;</description>
	<lastBuildDate>
	Sat, 02 Mar 2019 16:57:34 +0000	</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.1.1</generator>
	<item>
		<title>Interface</title>
		<link>https://danushka96.github.io/sigma/index.php/2018/04/13/interface/</link>
				<comments>https://danushka96.github.io/sigma/index.php/2018/04/13/interface/#respond</comments>
				<pubDate>Fri, 13 Apr 2018 04:38:20 +0000</pubDate>
		<dc:creator><![CDATA[Gayan Sampath]]></dc:creator>
				<category><![CDATA[OOP]]></category>
		<category><![CDATA[abstract class]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">https://danushka96.github.io/sigma/?p=855</guid>
				<description><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">3</span> <span class="rt-label rt-postfix">minutes</span></span> ආයුබෝවන් යාලුවවෝ හැමෝටම&#8230;oop පාඩම් මාලාවේ අවසන් පාඩමට ඔයාලා හැමෝම සාදරයෙන් පිලිගන්නවා&#8230;ඔයාලා දිගටම අපිත් එක්ක රැදී හිටියනම් මේ වෙනකොටත් oop වල තියන ගොඩක් දේවල් ඉගෙන ගෙන හමාරයි&#8230;oop වල මොකක් හරි පාඩමක් මග හැරුනනම් මෙතනින් ගිහින් බලන්න පුලුවන්&#8230;oop වල අවසාන්ම පාඩමෙන් මං කතා කරන්න බලාපොරොත්තු වෙන්නේ interface ගැන&#8230;පුරුදු විදියටම මුලින්ම මම කලින්<a class="moretag" href="https://danushka96.github.io/sigma/index.php/2018/04/13/interface/"> Read more&#8230;</a></p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/04/13/interface/">Interface</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></description>
								<content:encoded><![CDATA[<span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">3</span> <span class="rt-label rt-postfix">minutes</span></span><p><img class="alignnone size-medium wp-image-112" src="https://danushka96.github.io/sigma/wp-content/uploads/2018/03/oop-300x172.png" alt="" width="300" height="172" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/03/oop-300x172.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/03/oop.png 500w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>ආයුබෝවන් යාලුවවෝ හැමෝටම&#8230;oop පාඩම් මාලාවේ අවසන් පාඩමට ඔයාලා හැමෝම සාදරයෙන් පිලිගන්නවා&#8230;ඔයාලා දිගටම අපිත් එක්ක රැදී හිටියනම් මේ වෙනකොටත් oop වල තියන ගොඩක් දේවල් ඉගෙන ගෙන හමාරයි&#8230;oop වල මොකක් හරි පාඩමක් මග හැරුනනම් <a href="https://danushka96.github.io/sigma/index.php/category/oop/">මෙතනින්</a> ගිහින් බලන්න පුලුවන්&#8230;oop වල අවසාන්ම පාඩමෙන් මං කතා කරන්න බලාපොරොත්තු වෙන්නේ interface ගැන&#8230;පුරුදු විදියටම මුලින්ම මම කලින් පාඩම පොඩ්ඩක් මතක් කරලා ඉන්නම්කෝ&#8230;කලින් පාඩමේදී අපි කතා කලා abstract classes ගැන&#8230;body එකක් නැති එහෙමත් නැත්නම් meaningless body එකක් තියන method එකක් හරි ඊට වැඩි ගානක් හරි තියන class එකකට අපි කිව්වා abstract class එකක් කියලා&#8230;තව abstract class ගැන ගොඩක් විස්තර කතා කලා කලින් පාඩමේ..කලින් පාඩමේ තිබුන හැම දෙයක්මනම් මතක් කරන්න යන්නේ නෑ&#8230;අමතක නම් හරි අපෙ කලින් පාඩම බැලුවෙ නැත්තම් හරි මෙන්න <a href="https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/">මෙතනින්</a> ගිහින් ඉක්මනට බලලා එන්නකෝ..</p>
<p>හරි එහෙනම් අපි දැන් බලමු අද පාඩම ගැන..අද පාඩම interface කියලා මම කලින් කිව්වනේ..හරි එහෙනන් අපි මුලින්ම බලමු interface එකක් කියන්නේ මොකද්ද කියලා&#8230;interface කියන්නේ මොකද්ද කියලා කියන්න කලින් මං කියන්නම් ඇයි interface පාවිච්චි කරන්නේ කියලා&#8230;.හරි අපි කලින් පාඩමකින් කතා කලානේ <a href="https://danushka96.github.io/sigma/index.php/2018/03/25/object-oriented-programming-5/" target="_blank" rel="noopener">inheritance</a> ගැන&#8230;එතනදී අපි කලේ එක class එකකින් තවත් class. එකක් inherit කරපු එකනේ&#8230;ඒ කියන්නේ එක inheritance එකයි තිබුනේ&#8230;multiple inheritance ගැන අපි කතා කලේ වත් නෑනේ නේද&#8230;එහෙම කලේ multiple inheritance java වල නැති නිසා&#8230;(C++ වල නම් තියනවා) &#8230;multiple inheritance කියන්නේ මේ වගේ එකකට&#8230;</p>
<pre>class A{

      // statement

}

class B{

    // statement

}

class C extends <strong>A,B</strong>{

     // statement

}

</pre>
<p>ඔන්න ඕකට තමයි multiple inheritance කියලා කියන්නේ&#8230;<strong>එක class එකක් class ගොඩකින් inherit වෙන එකට</strong>&#8230;ඔන්න ඔය දේ කරන්න java language එකේ ඉඩදෙන්නේ නෑ&#8230;අන්න ඒ දුර්වලතාව මගහැර ගන්න තමයි interface පාවිච්චි කරන්නේ&#8230;interface එක හැසිරීම class එකකට ගොඩක් දුරට සමානයි&#8230;නමුත් class එකක් නම් නෙවෙයි&#8230;interface වලින් පුලුවන් class කිහිපයක තියන ලක්ෂණ එක class එකකට ගන්න&#8230;හරියට නිකන් inheritance පාවිච්චි කලා වගේ..abstract class ගැන කතා කලා වගේම interface වල තියන ලක්ෂණ ටිකක් මුලින්ම මං කියන්නම්&#8230;</p>
<p>interface එකක් අපි define කරන්නේ interface කියලා දාලා interface එකේ නම ලියනවා..මෙන්න මේ විදියට..</p>
<pre>interface myInterface{

// statement

}
</pre>
<p>ඔන්න ඔහොමයි interface එකක් define කරන්නේ&#8230;</p>
<p>interface එකක තියෙන තවත් විශේෂත්වයක් තමයි interface එකක තියා ගන්න පුලුවන් abstract methods විතරයි.. interface එකක් ඇතුලේ තියා ගන්නේ abstract method විතරයිනම් interface එකත් abstract වෙන්න ඕනි නේද&#8230;.interface එක abstract වූනා කියන්නේ object හදන්නත් බැහැ &#8230;object හදන්න බෑ කියන්නේ constractor එකකුත් නෑ නේද.. තව දෙයක් තියනවා , interface එකක් ඇතුලේ තියන methods ඔක්කොම public වෙන්නත් ඕනි abstract වෙන්නත් ඕනි static වෙන්නත් ඕනි&#8230;ඒ වගේම interface එක ඇතුලේ තියන attributes ඔක්කොම public වෙන්නත් ඕනි static වෙන්නත් ඕනි final වෙන්නත් ඕනි..තවත් දෙයක් තීයනවා.intercace එකක reference variable එකකට පුලුවන් implements වුන class එකේ objects store කරගන්නත්..හරියට නිකන් මෙන්න මේ වගේ..</p>
<pre>interface A{
     // statement
}

class B implements A{
     //  statement
}

class Demo {
     public static void main(String a[]){
   
             interface A=new B() // upcasting 

     }

}
</pre>
<p>ඕන්න ඔය ටික තමයි interface එකක තියන ප්‍රධාන විශේෂත්ව&#8230;</p>
<p>හරි දැන් අපි බලමු interface පාවිචි කරන්නේ කොහොමද කියලා&#8230;කලින් මං කිව්වනේ interface කියන්නෙත් inheritance වගේ කියලා&#8230;inheritance වලදි නම් එක class එකකින් තවත් class එකක් inherit කරන්නේ extends keyword එක පාවිච්චි කරලනේ&#8230;interface එකක් නම් implements  keyword එක දාලා තමයි class එකට සම්බන්ද කරන්නේ&#8230;මේ විදියට interface ඕනි ගානකින් එක class එකක් imlements කරන්න පුලුවන්..</p>
<pre>interface A{

         abstract void a();          // abstract method of interface A..

}

interface B{

         abstract void b();         // abstract method of interface B..

}

class X{

        int x;

        void a(){

        // statement ;               // not an abstract method

        }

}

class Demo extends X implements A,B{

       // statements;

}
</pre>
<p>Demo class එක X ගෙන් inherit කරලා තියනවා, A හා B ගෙන් imlements කරලා තියනවා&#8230;හරි ඔන්න ඔය විදියට තමයි class එකක් interface එකකින් implements කරන්නේ..හරි තේරුනා නේද වැඩේ&#8230;.interface ගැන ඉතිං ඔච්චරයි කියන්න තියෙන්නේ😃😃😃&#8230;තේරුනා නේද අද පාඩම&#8230;.ඔන්න ඔය පාඩමත් සමගම අපේ oop පාඩම් මාලාවත් නිමාවෙනවා&#8230;oop වල මොකක් හරි අව්ලක් ආවොත් ඉක්මනට comment එකක් දාන්න&#8230;අපි සූදානම් ඔයාලට උදව් කරන්න..හරි එහෙනන් මට යන්න අවසරයි 😃😃😃&#8230;තවත් අලුත් පාඩම් මාලාවක් සමගින් ඉක්මනටම හමුවෙමු&#8230;ස්තූතියි !</p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/04/13/interface/">Interface</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://danushka96.github.io/sigma/index.php/2018/04/13/interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>Abstract Class</title>
		<link>https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/</link>
				<comments>https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/#respond</comments>
				<pubDate>Thu, 12 Apr 2018 04:49:04 +0000</pubDate>
		<dc:creator><![CDATA[Gayan Sampath]]></dc:creator>
				<category><![CDATA[OOP]]></category>
		<category><![CDATA[abstract class]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[overriding]]></category>
		<category><![CDATA[super keyword]]></category>
		<category><![CDATA[this keyword]]></category>

		<guid isPermaLink="false">https://danushka96.github.io/sigma/?p=838</guid>
				<description><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">4</span> <span class="rt-label rt-postfix">minutes</span></span> ආයුබෝවන් ! oop පාඩම් මාලාවේ 11 වන දිගහැරුමත් සමග එකතු වෙන යාලුවෝ හැමෝම සාදරයෙන් පිලිගන්නවා&#8230;the sigma blog අඩවියත් සමග නිරන්තරයෙන් රැදී සිටි යාලුවෝ නම් මේ වෙනකොටත් object orianted programming ගැන ගොඩක් දේවල් ඉගෙනගෙන හමාරයි.ඔයා the sigma blog අඩවියට අලුත් සාමාජිකයෙක් නම් හරි , oop අව්ල් කෙනෙක් නම් හරි අපේ මුල්<a class="moretag" href="https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/"> Read more&#8230;</a></p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/">Abstract Class</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></description>
								<content:encoded><![CDATA[<span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">4</span> <span class="rt-label rt-postfix">minutes</span></span><p><img class="alignnone size-medium wp-image-112" src="https://danushka96.github.io/sigma/wp-content/uploads/2018/03/oop-300x172.png" alt="" width="300" height="172" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/03/oop-300x172.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/03/oop.png 500w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>ආයුබෝවන් ! oop පාඩම් මාලාවේ 11 වන දිගහැරුමත් සමග එකතු වෙන යාලුවෝ හැමෝම සාදරයෙන් පිලිගන්නවා&#8230;the sigma blog අඩවියත් සමග නිරන්තරයෙන් රැදී සිටි යාලුවෝ නම් මේ වෙනකොටත් object orianted programming ගැන ගොඩක් දේවල් ඉගෙනගෙන හමාරයි.ඔයා the sigma blog අඩවියට අලුත් සාමාජිකයෙක් නම් හරි , oop අව්ල් කෙනෙක් නම් හරි අපේ මුල් පාඩම් ටික <a href="https://danushka96.github.io/sigma/index.php/category/oop/">මෙතනින්</a> ගිහින් බලන්න අමතක කරන්නත් එපා හොදේ. හරි එහෙනන් පටාන් ගමු අද පාඩම&#8230;අද පාඩම තමයි abstract class &#8230;. abstract class ගැන කතා කරන්න ඉස්සරින් කලින් පාඩම පොඩ්ඩක් මතක් කරන්නම්&#8230;කලින් පාඩමේදී අපි කතා කලා. encapsulation ගැන&#8230;මොකද්ද අපි encapsulation කියලා කිව්වේ&#8230; class එකක තියන data protect කරන එක එහෙමත් නැත්නම් data ආරක්ෂා කරන එකට අපි කිව්වා encapsulation කියලා&#8230;. අපේ encapsulation පාඩම මතක නැතිනම් <a href="https://danushka96.github.io/sigma/index.php/2018/04/11/encapsulation/">මෙතනින්</a> ගිහින් ඉක්මනට බලනකෝ&#8230;එතකොට සුපිරියටම මතක් වෙයි.</p>
<p>හරි එහෙනම් අපි දැන් බලමු අද පාඩම ගැන..අද පාඩම තමයි abstract class .<br />
abstract class එකක් ගැන කියන්න ඉස්සරින් මං කියන්නම් abstract method එකක් කියන්නේ මොකක්ද කියලා&#8230;ඇත්තටම abstract කියන වචනයෙන්ම කියවෙනවා නේද &#8220;මොකුත් නෑ/හිස්&#8221; වගේ අදහසක්&#8230;ඒකම තමයි මේ class වලත් විශේෂත්වය&#8230;හැබැයි පොඩ්ඩක් වෙනස්&#8230;ඇත්තටම abstract method එකක් කියන්නෙ body එකක් නැති  එහෙමත් නැත්නම් meaningless body එකක් තියන method එකකට&#8230;abstract method එකක් define කරන්නේ method එක ඉදිරියෙන් abstract කියන වචනය දාලා&#8230;හරියට නිකන් මෙන්න මේ වගේ&#8230;</p>
<pre>class Person {

     abstract void Jump(){

     }

}
</pre>
<p>ඔන්න ඔය විදියට තමයි abstract method එකක් define කරන්නේ&#8230;class එකක් ඇතුලේ ඔය වගේ abstract method එකක් හරි ඊට වැඩි ගානක් හරි තිබ්බොත් අන්න ඒ class එකත් abstract class එකක් වෙනවා&#8230; හරි එහෙනම් Person class එක ඇතුලෙ තියනවා නේද jump කියලා abstract method එකක් එහෙනම් අපේ Person class එකත් abstract වෙන්න ඕනි නේද&#8230;</p>
<pre>abstract class Person {

         abstract void Jump(){

      }

}
</pre>
<p>ඔන්න ඔය වගේ class වලට තමයි abstract class එකක් කියන්නේ&#8230;abstract class මොකටද ගන්නේ කියලා අපි පසුව බලමු&#8230;දැනට මතක තියාගන්නකෝ abstract class එකක් කියන්නේ ඕන්න ඕකකට කියලා ☺☺..</p>
<p>මේ abstract class ගත්තොත් විශේෂතා ගොඩක් තියනවා&#8230;.abstract method එකකනම් ඒකේ body එකේ මොකුත් තියා ගන්න බෑ &#8230;නමුත් abstract class එකක් ගත්තොත් ඒකේ abstract methods තියෙන්නත් පුලුවන් abstract නොවන methods තියෙන්නත් පුලුවන්&#8230;ඔන්න ඕක එක විශේෂත්වයක් abstract class වල තියෙන&#8230;තවත් දෙයක් තමයි මේ abstract class වලට objects හදන්න බෑ&#8230;.object හදන්න බැහැ කියන්නේ constructor එකකුත් නැහැ..ඔන්න ඕක තවත් විශේෂත්වයක්&#8230;පොඩ්ඩක් මේ උදාහරණය දිහා බලන්නකෝ&#8230;</p>
<pre>abstract class Person{

       abstract void jump();

       void run(){

       system.out.println(" i can run fast !");

       }

}

class Student extends Person{

       void study(){

       system.out.println("i am studding !");

       }

}
</pre>
<p>හරි එහෙනම් ඔය class දෙක දිහා හොදට බලන්නකෝ&#8230;Person class එකෙන් Student class එක inherit වෙලා තියනවා .. එහෙනම් Person class එකේ තියන privet නොවන සියලුම attributes හා methods Student class එක ඇතුලට එනවා නේද&#8230;ඒ කියන්නේ Person class එකේ තියන jump කියන abstract class එකත් Student class එක ඇතුලට ඇවිත් තියෙන්නේ&#8230;කලින් මං කිව්වනේ class එකක් ඇතුලේ අඩුම එක abstract method එකක්වත් තිබ්බොත් class එක abstract වෙනවා කියලා&#8230;.එහෙනම් අපේ Student class එකත් මෙන්න මේ වගේ abstract කරන්න ඕනි නේද&#8230;</p>
<pre>abstract class Person{

         abstract void jump();

         void run(){

         system.out.println(" i can run fast !");

         }

}

abstract class Student extends Person{

         void study(){

         system.out.println("i am studding !");

         }

}
</pre>
<p>හරි ඔන්න ඔහොම තමයි අපේ code එක එන්නේ&#8230;කිසි අව්ලක් නෑ&#8230;නමුත් මට ඕනි Student කෙනෙක්ගේ object එකක් හදන්න&#8230;Student class එක abstract එකක් නිසා මට Student කෙනෙක්ගෙ object එකක් හදන්න compiler එක ඉඩ දෙන්නේ නෑ&#8230;එහෙනම් කොහොමද මං Student කෙනෙක්ගේ object එකක් හදන්නේ&#8230;Student class එකේ තියන abstract කෑල්ල අයන් කරානම් හරි නේද &#8230;එහෙම කරන්නම් abstract methods class එකෙන් අයින් කරන්න ඕනි&#8230;Student Class එකේ තියන jump method එකනේ abstract method එකකට තියෙන්නේ&#8230;අන්න ඒ jump method එකේ abstract බව අයින් කලානම් හරි නේද&#8230;ඒ කියන්නේ jump method එක Student class එක ඇතුලෙදී override කලා නම් හරි නේද&#8230;<a href="https://danushka96.github.io/sigma/index.php/2018/03/31/method-overriding/">override</a> කලාම jump method එකට body එකක් තියන නිසා ඒ method එකේ abstract බව auto නැතිවෙලා යනවා &#8230;.code එක ලිව්වොත් මෙන්න මේ වගේ</p>
<pre>abstract class Person{

         abstract void jump();

         void run(){

         system.out.println(" i can run fast !");

         }

}

class Student extends Person{

       void jump(){   

       system.out.println("i can jump !");        // overriding the abstract class

       }

       void study(){

       system.out.println("i am studding !");

       }

}
</pre>
<p>හරි දැන් මට අව්ලක් නැතිව Student object එක හදන්න පුලුවන් නේද&#8230;&#8230;<br />
abstract class වල තියන තව විශේෂත්වයක් තමයි , abstract class reference variable එකකට පුලුවන් sub class objects store කර ගන්න..(upcasting)..අපේ උදාහරණයේ විදියටනම් මෙන්න මේ දේ&#8230;</p>
<pre>Person person1= new Student();
</pre>
<p>හරි ඔන්න ඔය ටික තමයි abstract class ගැන කියන්න තියෙන්නේ&#8230; interface වලදී abstract class හොදටම පාවිච්චි වෙනවා&#8230;එතකොට ඔයාලට තවත් හොදට තේරෙයි&#8230;</p>
<p>හරි අපි abstract class ගැන කතා කලානේ&#8230;දැන් මං කතා කරන්න හදන්නේ java වල තියෙන වැදගත් key word දෙකක් ගැන..කලින් අපි <a href="https://danushka96.github.io/sigma/index.php/2018/03/31/method-overriding/">super keyword</a> එක ගැනයි <a href="https://danushka96.github.io/sigma/index.php/2018/03/21/object-oriented-programming-4/">this keyword</a> එක ගැනයි කතා කලනේ..අද කතා කරන්න යන්නේ final keyword එක ගැනයි static keyword එක ගැනයි&#8230;</p>
<p>final keyword :</p>
<p>ඇත්තටම කියනවනම් final keyword එකෙන් කරන්නේ variable එකකට නිශ්චිත constant value එකක් assign කරන එක&#8230;උදාහරණයක් විදියට ගත්තොත් වෘත්තයක ව.ඵ හොයද්දි අපට ඕනි වෙන £ =3.14 කියන අගය&#8230;අපිට ඒක final keyword එක දාලා මේ විදියට define කෙරුව හැකි.</p>
<pre>final float £ = 3.14 ; 
</pre>
<p>ඔන්න ඕක තමයි final keyword එකෙන් කරන්නේ&#8230;</p>
<p>static keyword:</p>
<p>static keyword එකනම් ටිකක් වැදගත් keyword එකක්&#8230;අපිට static keyword එක දාලා attributes define කරන්නත් පුලුවන් methods define කරන්නත් පුලුවන්&#8230;attributes එකක් static කලොත් ඒ attribute එකේ value එක program එක අවසන් වුනත් නොවෙනස්ව පවත්වා ගන්න පුලුවන්..හරියට නිකන් මෙන්න මේ වගේ&#8230;</p>
<pre>class Cat{

     int age;

     static int numOfSibligs=0;

     void run(){

          System.out.print("it can be run fast !");

     }

}

Class Demo{

      public static void main(String a[]){

              Cat cat1= new Cat(); // creating a cat object

              numOfSibligs ++;

              System.out.println("cat1 has "+ cat1.numOfSibligs +" sibligs");

              Cat cat2= new Cat(); //creating another object

              numOfSibligs ++ ;

              System.out.println("cat2 has "+ cat2.numOfSibligs +" sibligs");

      }

}
</pre>
<p>සාමාන්‍ය variable එකක නම් object එක එක පාරක් හැදුවහම එහි අගය lost වෙලා යනවා. නමුත් static keyword එක පාවිච්චි කලොත් එහෙම වෙන්නෙ නැහැ . out put එකකවත් පොඩ්ඩක් බලන්නකෝ.</p>
<p>Out put :</p>
<p><img class=" wp-image-839 aligncenter" src="https://danushka96.github.io/sigma/wp-content/uploads/2018/04/Capture1-300x154.jpg" alt="" width="565" height="290" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/04/Capture1-300x154.jpg 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/04/Capture1.jpg 610w" sizes="(max-width: 565px) 100vw, 565px" /></p>
<p>ඔන්න ඕකයි attribute එකක් static කලාම වෙන්නේ&#8230;දැන් අපි බලමු method එකක් static කලාම මොකද වෙන්නේ කියලා&#8230;ඇත්තටම method එකක් static කලාම , ඒ method එකට call කරන්න පුලුවන් object එකක් හදන්නේ නැතිව.ඒ කිව්වේ මෙන්න මේකයි.</p>
<pre>class Cat{

     int age;

     static int numOfSibligs=0;

     static void run(){

          System.out.print("it can be run fast !");

     }

}

class Demo{

      public static void main(String a[]){

              Cat.run();

              

      }

}
</pre>
<p>output :</p>
<p><img class=" wp-image-840 aligncenter" src="https://danushka96.github.io/sigma/wp-content/uploads/2018/04/Capture2-300x144.jpg" alt="" width="544" height="261" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/04/Capture2-300x144.jpg 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/04/Capture2.jpg 526w" sizes="(max-width: 544px) 100vw, 544px" /></p>
<p>ඔන්න ඕක තමයි static keyword එකෙන් වෙන්නේ&#8230;</p>
<p>හරි අදට පාඩම හමාරි..😃😃&#8230;හැමෝටම තේරුනා කියලා හිතනවා&#8230;මොකක් හරි අව්ලක් තිබුනොත් පහලින් comment එකක් දාන්න&#8230;oop වල අවසාන පාඩමත් සමගින් හමුවෙමූ. සුභ දවසක් !</p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/">Abstract Class</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://danushka96.github.io/sigma/index.php/2018/04/12/abstract-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
