Results 1 to 2 of 2
Thread: UpperCase problem
- 08-04-2008, 12:16 AM #1
Member
- Join Date
- Aug 2008
- Posts
- 1
- Rep Power
- 0
UpperCase problem
Hello everyone .....
I am new in java i start learn it from 3 weeks ago so i don't know much abut java .
i want to write a program that ask the user to enter his/her name and the program will print the first name as it is and the last name will be in UpperCase .
the code it print this error " <identifier> expected "
Java Code:import javax.swing.*; public class PrintUser { public static void main(String[]args) { String names=JOptionPane.showInputDialog(null,"Enter your Name :"); System.out.println(names); UserName r=new UserName(); JOptionPane.showMessageDialog(null,names); System.out.println(); } } class UserName { char ch; char prevCh; String names; int i; prevCh='.'; void r(String[]args); { for (i=0;i<names.length();i++ ) { ch = names.charAt(i); if ( Character.isLetter(ch) && ! Character.isLetter(prevCh) ) System.out.print( Character.toUpperCase(ch) ); else System.out.print(ch); prevCh = ch; } } }
- 08-04-2008, 12:26 AM #2
Similar Threads
-
String uppercase/lowercase
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 10:22 AM
Bookmarks