This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-22 13:09:06

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Java, how to?

In Java, I'm sure many of ye' here are familiar with the language, how would I do this?

void method(){
//some code
}
String name = "me";

so how would I do

name+"thod"();

? It's kinda self-explainitory, but hard to explain. Thanks.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#2 2012-05-22 13:14:28

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Java, how to?

Please reply quick. My life depends on this!

(Well, obviously not really  tongue )


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#3 2012-05-22 13:16:21

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Java, how to?

That is tough. I don't know how to but it is possible. Try exploring java.lang.reflect.Method


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#4 2012-05-22 13:18:17

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Java, how to?

I've actually been looking for an answer, kind've like "exec()" in python, am I right?


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#5 2012-05-22 14:01:36

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Java, how to?

H-hem, more answers please.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#6 2012-05-22 15:15:47

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java, how to?

For me I can quite simply do System.out.println(hi + "thod"); assuming hi equals 'me'.

Offline

 

#7 2012-05-22 15:42:43

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Java, how to?

maxskywalker wrote:

For me I can quite simply do System.out.println(hi + "thod"); assuming hi equals 'me'.

S/he means calling a method using a string. Like "main"();


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#8 2012-05-22 18:40:44

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: Java, how to?

There is somewhere I think has a JVM built in Java.  Is that what you are looking for?

Last edited by SJRCS_011 (2012-05-22 21:35:40)


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#9 2012-05-22 18:54:22

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Java, how to?

SJRCS_011 wrote:

There is so where i remember that is a JVM built in Java.  Is that what you are looking for?

Ohhhh.  Yeah, no ideas.

Offline

 

#10 2012-05-22 19:16:50

matthew8092001
Scratcher
Registered: 2010-09-12
Posts: 100+

Re: Java, how to?

Maybe you could create an enum?  smile


http://1.bp.blogspot.com/_GVA115I1I8Y/TMGwbJ056kI/AAAAAAAABHs/kpvg0oCKV2g/s1600/happy.gif
lol

Offline

 

#11 2012-05-22 21:36:16

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: Java, how to?

maxskywalker wrote:

SJRCS_011 wrote:

There is a JVM built in Java somewhere.  Is that what you are looking for?

Ohhhh.  Yeah, no ideas.

gr, i hate iDevice Auto-correct


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#12 2012-05-23 02:31:48

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Java, how to?


http://i.imgur.com/1QqnHxQ.png

Offline

 

Board footer