aspose file tools*
The moose likes Beginning Java and the fly likes Conversion Of string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Conversion Of string" Watch "Conversion Of string" New topic
Author

Conversion Of string

Subhash Pavuskar
Ranch Hand

Joined: Jun 29, 2011
Posts: 57

Can any one give me the Code to Convert String Upper case to lower case and vice versa Without using Function.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14338
    
  22

Well, that is going to be very hard, because there is no way to get at the characters inside a string without calling any method of the String class.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Most here will not write the code and give it to you. It's a bit insulting that you'd ask.

However, if you try to write the code and need help along the way, many here are waiting for you to ask and would be honored to provide assistance.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14338
    
  22

Greg Brannon wrote:Most here will not write the code and give it to you. It's a bit insulting that you'd ask.

I don't think it is insulting to ask, but here at JavaRanch we want to help people learn Java. People don't learn Java by having their homework questions answered by others. So, we don't provide answers to homework questions; instead we encourage people to first try something themselves, and if someone doesn't know how to proceed, we're happy to show and explain the right direction.
Subhash Pavuskar
Ranch Hand

Joined: Jun 29, 2011
Posts: 57

This question is asked me in interview and i dint get idea how to code for that so i asked ... but my intention was not insulting or hearting any one .
Subhash Pavuskar
Ranch Hand

Joined: Jun 29, 2011
Posts: 57

thanks for your support Mr. Jesper de Jong ..
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Subhash Pavuskar wrote:This question is asked me in interview and i dint get idea how to code for that so i asked ... but my intention was not insulting or hearting any one .

No harm done - by you, anyway.
Giving the background you just gave would have been helpful in answering your question.
Function is not a word used in Java that has a common meaning to all. Do you know what the interview question meant by the word "function."
Subhash Pavuskar
Ranch Hand

Joined: Jun 29, 2011
Posts: 57

I meant i cant use the function toUpperCase and toLowerCase .
Claudiu Chelemen
Ranch Hand

Joined: Mar 25, 2011
Posts: 71

Maybe there is a constant number found inbetween the lowercase letters and uppercase ones, while watching the ascii table ?
Let's say the distance between 'a' and 'A' is 32. Hint: What would it be between 'b' and 'B' ?

Cheers
Claudiu
Subhash Pavuskar
Ranch Hand

Joined: Jun 29, 2011
Posts: 57

Oh ya you are right we can solve this using ascii value good work Claudiu..
thanks.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11475
    
  16

This is one of those questions where there is no real answer. If it was posed by an interviewer, they wanted to see how you'd think about the problem. If they are a bad interviewer, they have some trick or hack in mind, and unless you come up with THEIR hack, they mark you down.

I would ask the interviewer "Why can't I use the methods?"

if they insist, my first thought would be to construct a StringBuffer from the String, and use its methods.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
There are also methods in the Character class which allow you to work out whether a char is upper-case or lower-case. The trick about adding 32 (actually it would look better if you said 0x20, then you can catch out the interviewer) might only work for ASCII characters.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

Claudiu Chelemen wrote:Maybe there is a constant number found inbetween the lowercase letters and uppercase ones, while watching the ascii table ?
Let's say the distance between 'a' and 'A' is 32. Hint: What would it be between 'b' and 'B' ?


Or maybe there isn't such a constant... the distance between 'ă' and 'Ă' is not 32, but -1.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion Of string