Results 1 to 6 of 6

Thread: Definition of a String in Java?

  1. #1
    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.

  2. #2
    Join Date
    May 2011
    Posts
    97

    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

  3. #3
    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.

  4. #4
    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.

  5. #5
    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

  6. #6
    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.

Similar Threads

  1. The String Class in Java
    By blueprats in forum Guides & Tutorials
    Replies: 3
    Last Post: 12-03-2010, 02:44 PM
  2. String to uppercase in java
    By ISAIAH in forum Software Development
    Replies: 5
    Last Post: 24-02-2010, 12:33 AM
  3. Separating a string in java
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 10-02-2010, 04:27 AM
  4. Java String test
    By Aidan 12 in forum Software Development
    Replies: 3
    Last Post: 09-11-2009, 02:22 PM
  5. How to convert string into int in Java
    By Zool in forum Software Development
    Replies: 3
    Last Post: 09-11-2009, 12:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,694,787.97087 seconds with 17 queries