473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 "in this line prevCh='.';


[PHP]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;
}

}


} [/PHP]
Aug 4 '08 #1
1 1349
JosAH
11,448 Expert 8TB
Between the outer two curly brackets of a class you can rougly put other classses
and interfaces and defintions (such 'char ch') and method definitions only. You
put a statement there (prevCh= '.') which is not allowed. Statement belongs
inside methods or in initialization blocks.

kind regards,

Jos
Aug 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Vangelis Natsios | last post by:
I'm trying to provide a case-insensitive search in greek texts from a jsp page. The check goes like this: if (el_title.toUpperCase().indexOf(selected_title.toUpperCase()) { .... } where...
23
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner,...
5
by: Paul Schwann | last post by:
Hi everybody, I have a problem with the following code: #include <iostream> int main(void) { std::cout << std::hex << std::uppercase << 31 <<std::endl; return 0;
3
by: Jurrie | last post by:
Hi all, Is there a function or something in XSLT or XSL-FO to make data from an XML-file uppercase? I ask this becouse I have a XML-document with <title>whatever</title> tags, and i want the...
8
by: Markus Dehmann | last post by:
My ios::uppercase (and others) seems not to work. #include <iostream> using namespace std; int main(){ int num = 45; cout.setf(ios::hex | ios::showbase | ios::uppercase); cout << "number " <<...
1
by: Beffmans | last post by:
How can I turn the Uppercase mode on in my TextBoxes? ch B. *** Sent via Developersdex http://www.developersdex.com ***
9
by: humaid | last post by:
hi guys,i have this problem.first let me show you the so far code #!/user/bin/perl while ($a = <STDIN>) { if ($a =~ tr/A-Z/a-z/) { print "$a\n"; }
6
by: 182719 | last post by:
<?php $testcase = 'AKLWC139'; if (ctype_upper($testcase)) { echo "The string $testcase consists of all uppercase letters. \n"; } else { echo "The string $testcase does not consist of all...
4
by: Hrsoft | last post by:
I'm a newbie with asp.net I need to transform a user textbox to uppercase, when typing. Is this possible? I read about Ajax Maskedit, but it is only to certain formats, like dates, etc Thanks...
1
by: Newcomsas | last post by:
Hello. I'm trying to solve a little problem with an uppercase function. It looks like this: function uppercase() { key = window.event.keyCode; if ((key 0x60) && (key < 0x7B))...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.