strings are immutable in java...so can we apply toupper nd tolower function directly in a string
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
strings are immutable in java...so can we apply toupper nd tolower function directly in a string
Are you talking about the java SE String class? Look at the API doc for how to use the methods that you are asking about. If you have any questions about the doc, copy the text here and ask your questions about it.
Last edited by Norm; September 21st, 2014 at 10:40 AM. Reason: Fix spelling
If you don't understand my answer, don't ignore it, ask a question.
import static java.lang.System.*;
import java.util.Scanner;
class StringTest3
{
public static void main(String args[])
{
String str = "Unisoft Technologies"; //immutable
out.println(str);
String temp;
temp = str.replace("soft","hardware");
out.println(temp);
temp = str.toUpperCase();
out.println(temp);
temp = str.toLowerCase();
out.println(temp);
temp = str.concat(", Dehradun");
out.println(temp);
}
}
i want to know,if strings are immutable in java,so how i become able to change the given string into uppercase,lowercase,even iam able to concatenate it with other string
Threads merged.
Please don't start multiple threads on the same topic.
You should also know how to post your code using code or highlight tags as explained near the top of this topic. If you need help with that, PM me.
Do you have a question?
Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings.
I'm not quite sure I understand your question but to me it looks like you're asking if we can modify a String to its lowercase or uppercase variant in which case the answer is yes:
public class UpperAndLower { public static void main(String[] args) { String lower = "LowEr"; String upper = "uPPeR"; System.out.println(lower.toLowerCase() + " - " + upper.toUpperCase()); } }