Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
JAVA WADDOOOOOOOO warellaaa
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="NO_MeRcY" data-source="post: 18369146" data-attributes="member: 289641"><p><span style="font-family: 'Arial'"><span style="font-size: 15px"><strong>Options කීපයක් තියනවා මල්ලී මම දෙකක් කියන්නම්</strong></span></span></p><p></p><p>[CODE]</p><p> public static void main(String[] args) { </p><p></p><p> Scanner sc = new Scanner(System.in);</p><p> int input = 0;</p><p></p><p> while (true) {</p><p> System.out.print("Enter number:");</p><p> input = sc.nextInt();</p><p> if (input < 900) {</p><p> System.out.print(input);</p><p> break;</p><p> } else {</p><p> System.out.println("Invalid Input");</p><p> }</p><p> }</p><p> }</p><p>[/CODE]</p><p></p><p></p><p>[CODE]</p><p> public static void main(String[] args) {</p><p></p><p> Scanner sc = new Scanner(System.in);</p><p> int input = 0; </p><p> do {</p><p></p><p> System.out.print("Enter number:");</p><p> input = sc.nextInt();</p><p></p><p> if (input > 900) {</p><p> System.out.println("Invalid Input");</p><p> }</p><p></p><p> } while (input > 900);</p><p></p><p> System.out.println(input); </p><p> }</p><p></p><p>[/CODE]</p><p></p><p><span style="font-size: 15px"><strong>මේ දෙකෙන් 2nd එක යූස් කරන්න මල්ලී. මොකද while loop එකකට එකක් break; දාන එක java best practice එකක් නෙමේ</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><strong><span style="font-size: 15px">exceptions එහෙම handle කරල code එක හදා ගනින්. </span></strong></p><p></p><p>Apart from the above </p><p></p><p> මම logic එක නම් කියෙව්වේ නැහැ. පේන විදියට එකත් තව fine tune කරන්න පුලුවන්. </p><p> </p><p>උබ දාල තියෙන code එකේ පොඩි වෙනස් කම් ටිකක් කරපන් මෙහෙම</p><p></p><p>> concatenation වලට String literals use කරන්න එපා. StringBuilder යූස් කරන්න.නැත්නම් performance ප්රශ්නයක් වෙයි. Modern JRE ඔය වැඩේ අපිට auto කරන දෙනවා ඒත් best practice එකක් විදියට StringBuilder යූස් කරන්න.</p><p></p><p>> [CODE]</p><p></p><p> StringBuilder sb = new StringBuilder();</p><p> sb.append(denom.values()[i - 1]).append(" ").append(text);</p><p> [/CODE]</p><p></p><p></p><p>> class variables public විදියට යූස් කරන්න එපා (උබ වෙන තැනක access කරන්නෙ නැත්නම්)</p><p></p><p>> try catch දාල exceptions handle කරන්න. </p><p> E.g. උබගේ මෙන්න මේ line එකෙන් java.lang.ArrayIndexOutOfBoundsException එක පනිනවා</p><p> [CODE] text = tens.values()[num - 2] + " " + text;[/CODE]</p><p></p><p></p><p>> Enum වල elements වලට CAPITAL LETTERS use කරන්න</p><p></p><p>> long Tens should be long tens</p></blockquote><p></p>
[QUOTE="NO_MeRcY, post: 18369146, member: 289641"] [FONT="Arial"][SIZE="4"][B]Options කීපයක් තියනවා මල්ලී මම දෙකක් කියන්නම්[/B][/SIZE][/FONT] [CODE] public static void main(String[] args) { Scanner sc = new Scanner(System.in); int input = 0; while (true) { System.out.print("Enter number:"); input = sc.nextInt(); if (input < 900) { System.out.print(input); break; } else { System.out.println("Invalid Input"); } } } [/CODE] [CODE] public static void main(String[] args) { Scanner sc = new Scanner(System.in); int input = 0; do { System.out.print("Enter number:"); input = sc.nextInt(); if (input > 900) { System.out.println("Invalid Input"); } } while (input > 900); System.out.println(input); } [/CODE] [SIZE="4"][B]මේ දෙකෙන් 2nd එක යූස් කරන්න මල්ලී. මොකද while loop එකකට එකක් break; දාන එක java best practice එකක් නෙමේ [/B][/SIZE] [B][SIZE="4"]exceptions එහෙම handle කරල code එක හදා ගනින්. [/SIZE][/B] Apart from the above මම logic එක නම් කියෙව්වේ නැහැ. පේන විදියට එකත් තව fine tune කරන්න පුලුවන්. උබ දාල තියෙන code එකේ පොඩි වෙනස් කම් ටිකක් කරපන් මෙහෙම > concatenation වලට String literals use කරන්න එපා. StringBuilder යූස් කරන්න.නැත්නම් performance ප්රශ්නයක් වෙයි. Modern JRE ඔය වැඩේ අපිට auto කරන දෙනවා ඒත් best practice එකක් විදියට StringBuilder යූස් කරන්න. > [CODE] StringBuilder sb = new StringBuilder(); sb.append(denom.values()[i - 1]).append(" ").append(text); [/CODE] > class variables public විදියට යූස් කරන්න එපා (උබ වෙන තැනක access කරන්නෙ නැත්නම්) > try catch දාල exceptions handle කරන්න. E.g. උබගේ මෙන්න මේ line එකෙන් java.lang.ArrayIndexOutOfBoundsException එක පනිනවා [CODE] text = tens.values()[num - 2] + " " + text;[/CODE] > Enum වල elements වලට CAPITAL LETTERS use කරන්න > long Tens should be long tens [/QUOTE]
Insert quotes…
Verification
Hata thunen beduwama keeyada? (60 bedeema thuna)
Post reply
Top
Bottom