About 561,000 results
Open links in new tab
  1. Create new object from a string in Java - Stack Overflow

    Apr 22, 2019 · Is there a way to create a new class from a String variable in Java? String className = "Class1"; //pseudocode follows Object xyz = new className(param1, param2); …

  2. java - How do you create a String object - Stack Overflow

    Jul 6, 2013 · Java compiler has special syntax for creating string objects from string literals. When you write. Java creates a new String object, ans assigns it to stringObj. Note that this is not …

  3. What are different ways to create a string object in Java?

    Feb 2, 2024 · Here, we are discussing two ways to create the string object in Java, By using String Literal; By using new Keyword; Now, we will discuss each way given above in detail …

  4. java - How to create JSON Object using String? - Stack Overflow

    Nov 21, 2013 · I want to create a JSON Object using String. Example : JSON {"test1":"value1","test2":{"id":0,"name":"testName"}} In order to create the above JSON I am …

  5. Create String Object in Java - Online Tutorials Library

    Creating an object of the String class using the new keyword by passing the string value as a parameter of its constructor. Passing a character array to the String constructor. Learn how to …

  6. String Literal Vs String Object in Java - GeeksforGeeks

    May 5, 2025 · In Java, we can use String Object to initialize a string. With the help of new keyword we can create string object. Declaration: String str = new String ("GeeksForGeeks") …

  7. Create a String object in Java Example - Source Code Examples

    This tutorial will demonstrate different methods to create a String object in Java, highlighting the most commonly used techniques. - Strings can be created using string literals or by using the …

  8. Learn How to Declare String in Java with Examples - Edureka

    Feb 13, 2025 · There are two ways to create a String object: By string literal: Java String literal is created by using double quotes. For Example: String s= “Welcome”; By new keyword: Java …

  9. Different Ways to Create Objects in Java - GeeksforGeeks

    Mar 28, 2025 · In this article, we will discuss five different methods to create objects in Java, and going to discuss how each one works internally. Now, we are going to discuss each of these …

  10. Java how to instantiate a class from string - Stack Overflow

    Jan 21, 2012 · If I want to instantiate a class that I retrieved with forName(), I have to first ask it for a java.lang.reflect.Constructor object representing the constructor I want, and then ask that …

Refresh