Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Instance name from string

Name: Anonymous 2011-01-20 17:00

Guys, I've been looking what feels like everywhere for an answer to this java.reflection problem.

I want to use the contents of a string to create and instance of an object that has the name of what the string stores.

Eg.
String[] carName = {"volvo","vw","bmw"};

car carName[0];
car carName[1];
car carName[2];

Name: Instdnce ndme from string 2011-01-20 17:07

Guys, I've been looking whdt feels like everywhere for dn dnswer to this jdvd.reflection problem.

I wdnt to use the contents of d string to credte dna instdnce of dn object thdt hds the ndme of whdt the string stores.

Eg.
String[] cdrNdme = {"volvo","vw","bmw"};

cdr cdrNdme[0];
cdr cdrNdme[1];
cdr cdrNdme[2];

Name: Anonymous 2011-01-20 17:08

This post looks half-finished.

Why don't you just not bother? It's a waste of time and resources.

Name: Anonymous 2011-01-20 17:08

ruby can do this.

Name: Anonymous 2011-01-20 17:08

>>2
nice.

>>2
I lol'd

Name: Anonymous 2011-01-20 17:09

typedef struct{void*car;void*cdr;}cons;

Name: Anonymous 2011-01-20 17:27

>>3
Me asking you this or coding this?

Name: Anonymous 2011-01-20 17:33

>>7
Coding it. If you really want reflection, either use a different language, or keep it confined to toy programs.

Name: Anonymous 2011-01-20 17:35

Car car = (Car) Class.forName("Volvo").newInstance();

Name: Anonymous 2011-01-20 17:36

>>8
This is just a part of a bigger project. I am not going to switch to a different language as java has a library that is basic for my code.

Name: Anonymous 2011-01-20 17:42

>>9
This looks promising but returns
"Unhandled exception type ClassNotFoundException"

[And no, I didn't forget to define the class, if I hadn't it would return
"Cannot find a class or type named "Car""]

Name: VIPPER 2011-01-20 17:43

I do not understand much about java or programning and not even about computers.
But i know one thing for sure:
MY OTHER CAR IS A CDR, BITCHES!!!!!

JEWS

Name: Anonymous 2011-01-20 17:53

>>11
you need a class named Volvo that implements the interface Car

Name: Anonymous 2011-01-20 17:53

Car car = (Car) Class.forName("Cudder").newInstance();

Name: Anonymous 2011-01-20 17:58

role Suck { ... }
class Faggot { ... }
class Dumb { ... }
class OP is Faggot does Suck { ... }

our OP $poster1 = new OP but Dumb;

Name: Anonymous 2011-01-20 18:03

The nice thing about /prog/ as opposed to other programming forums is that posts like >>1, are invariably trolls.
The con is, it's still not a very good or entertaining troll.

Name: Anonymous 2011-01-20 18:46

>>16
I think it's a legit question, actually.

Name: Anonymous 2011-01-20 18:54

>>17
How do you figure?

Name: Anonymous 2011-01-20 19:03

>>18
I don't know about you, but I am incapable of bringing my intelligence level to enable myself to write something like >>1. In other words, it's too stupid to be a troll.

Name: meh 2011-01-20 19:04

>>19
s/level/level low enough in order to/

Don't change these.
Name: Email:
Entire Thread Thread List