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
Bodim.lk out now !
Manoj Suranga Bandara
Updated:
Today at 3:05 AM
Power Lifting Lever Belt
SkullVamp
Updated:
Jun 13, 2026
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Jun 13, 2026
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Jun 11, 2026
Ad icon
Wechat qr verification
Pawan2005
Updated:
Jun 11, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Jobs & Employment
Programming interview - written tests
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="Anonymous_Abstract" data-source="post: 24659395" data-attributes="member: 568286"><p><span style="font-size: 18px"> Method Create for Proper Case</span></p><p></p><p><span style="font-size: 15px"><span style="color: Blue">package com.benz.test;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue">public class Reverse {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> public static void main(String[] args)</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> Reverse rev=new Reverse();</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> String nstr = rev.toProper("hEllo WORld beNz hOW are yoU");</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> System.out.println(nstr);</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> }</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> public void reverse(int value)</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> int rem;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> while(value>0)</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> rem = value % 10;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> System.out.print(rem);</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> value = value/10;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> }</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> }</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> </span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> public String toProper(String str)//hEllo WORld</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> if(str.trim().length()>0)</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> String newstr=null;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> str =str.toLowerCase();//hello world</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> String[] st = str.split(" ");//hello , world</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> char[] ch=null;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> for(String s : st)</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> {</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">ch = s.toCharArray(); //'h' 'e' 'l' 'l' 'o' , 'w' 'o' 'r' 'l' 'd'</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> ch[0] = Character.toUpperCase(ch[0]);//'H' ,'W'</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> if(newstr==null)</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> newstr = new String(ch);</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> else</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> newstr +=" "+ new String(ch);</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> }</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> return newstr;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> </span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> }else</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> return str;</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"> }</span></span></p><p><span style="font-size: 15px"><span style="color: Blue">}</span></span></p><p><span style="font-size: 15px"><span style="color: Blue"></span></span></p></blockquote><p></p>
[QUOTE="Anonymous_Abstract, post: 24659395, member: 568286"] [SIZE="5"] Method Create for Proper Case[/SIZE] [SIZE="4"][COLOR="Blue"]package com.benz.test; public class Reverse { public static void main(String[] args) { Reverse rev=new Reverse(); String nstr = rev.toProper("hEllo WORld beNz hOW are yoU"); System.out.println(nstr); } public void reverse(int value) { int rem; while(value>0) { rem = value % 10; System.out.print(rem); value = value/10; } } public String toProper(String str)//hEllo WORld { if(str.trim().length()>0) { String newstr=null; str =str.toLowerCase();//hello world String[] st = str.split(" ");//hello , world char[] ch=null; for(String s : st) { ch = s.toCharArray(); //'h' 'e' 'l' 'l' 'o' , 'w' 'o' 'r' 'l' 'd' ch[0] = Character.toUpperCase(ch[0]);//'H' ,'W' if(newstr==null) newstr = new String(ch); else newstr +=" "+ new String(ch); } return newstr; }else return str; } } [/COLOR][/SIZE] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom