Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Definition of a String in Java?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-02-2012
Member
 
Join Date: Jan 2012
Posts: 12
Definition of a String in Java?
  

Can someone please define a String in Java in as much detail as possible? Thanks so much.

Reply With Quote
  #2  
Old 17-03-2012
Member
 
Join Date: May 2011
Posts: 95
Re: Definition of a String in Java?

You can find more information on this in the below document with example. You can read the same to get idea on string. Oracle has awesome documentation for this. You can view many similar articles on its official site.


Class String

Strings
Reply With Quote
  #3  
Old 28-03-2014
Member
 
Join Date: Mar 2014
Posts: 2
Re: Definition of a String in Java?

Quote:
Originally Posted by cloud101 View Post
Can someone please define a String in Java in as much detail as possible? Thanks so much.
Hey hi ,

"String" is a sequence of characters. But in Java, string is an object. String class is used to create string object.
When you create a string literal, the JVM checks the string constant pool first. If the string already exists in the pool, a reference to the pooled instance returns. If the string does not exist in the pool, a new String object instantiates, then is placed in the pool.For example:

String s="Hello";
String s1="Hello";

Here s, s1 point towards Hello , no new object is created.
Reply With Quote
  #4  
Old 28-04-2014
Member
 
Join Date: Apr 2014
Posts: 3
Re: Definition of a String in Java?

Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects.

The Java platform provides the String class to create and manipulate strings.
Reply With Quote
  #5  
Old 29-04-2014
Member
 
Join Date: Apr 2014
Posts: 3
Re: Definition of a String in Java?

While for most programming languages, ?string? is a sequence of characters, for Java string is an object
Reply With Quote
  #6  
Old 28-07-2014
Member
 
Join Date: Oct 2013
Posts: 41
Re: Definition of a String in Java?

The string is a class built into the Java language defined in the Java.lang package. It symbolize character strings. Strings are ubiquitous in Java.
Strings are generally used in Java programming, or a sequence of characters. In the Java programming language, strings are objects. The Java platform provides a String class to create & manipulate strings in the right manner. The most common way to create string are:

String greeting = "Hello world!";

It encounters a string literal in your code, and compiler create a string object with its value in this case, ?Hello world!?

You can create string objects with the help of a new keyword and constructor. String class has 11 constructors which allow you to provide initial values of the string using several sources, such as an array of characters.

public class StringDemo{

public static void main(String args[]){
char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.'};
String helloString = new String(helloArray);
System.out.println( helloString );
}
}


This would proceduce following result

hello.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Definition of a String in Java?"
Thread Thread Starter Forum Replies Last Post
The String Class in Java blueprats Guides & Tutorials 3 12-03-2010 02:44 PM
String to uppercase in java ISAIAH Software Development 5 24-02-2010 12:33 AM
Separating a string in java Aaliya Seth Software Development 5 10-02-2010 04:27 AM
Java String test Aidan 12 Software Development 3 09-11-2009 02:22 PM
How to convert string into int in Java Zool Software Development 3 09-11-2009 12:41 PM


All times are GMT +5.5. The time now is 04:12 AM.