This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Create object Without new operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Create object Without new operator" Watch "Create object Without new operator" New topic
Author

Create object Without new operator

Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
Here is my program.
An object 'object' is created using the new operator.
I want to create an object without using the new operator.
Can you suggest how?

****************************************

code:


import java.io.*;

public class AQuestion7
{
String name="Manoj Kumar Paul";


public void check()
{
System.out.println("Substring = "+name.substring(0));
System.out.println("Substring = "+name.substring(9));
System.out.println("Substring = "+name.substring(0,5));

name=name.replace('a','s');
System.out.println("My name is = "+name);
}

public static void main(String args[])
{
AQuestion7 object = new AQuestion7();
object.check();
}
}


****************************************
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
You can you reflection to create objects without the new operator.


Rahul Bhattacharjee
LinkedIn - Blog
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

substring returns a new Object
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create object Without new operator
 
Similar Threads
Capitalize first letter in string
Strings and mutablelity
Create object Without new operator
Without new operator
Without new operator