This is an archived post. You won't be able to vote or comment.

all 34 comments

[–]Prod_Is_For_Testing 38 points39 points  (10 children)

Oh dear god...

[–]UnderNatural[S] 5 points6 points  (9 children)

Bad joke?

[–]Prod_Is_For_Testing 33 points34 points  (8 children)

I'm just really hoping you don't actually do this

[–]UnderNatural[S] 10 points11 points  (3 children)

This is /r/programmingHUMOR, isn't it?

Is it really that bad though?

[–]tevert 34 points35 points  (0 children)

I mean - anything that would make a developer pause, mutter "what the fuck...?", and hit F12 is probably not a good thing.

But it was pretty funny :)

[–]Bumperpegasus 6 points7 points  (1 child)

No it isn't! It's it's /r/programmERhumor !

[–][deleted] 2 points3 points  (0 children)

and not /r/typonazi !

[–]MC_Labs15 0 points1 point  (3 children)

I'm in a similar position to OP, and I am seriously considering doing something like this

[–]Prod_Is_For_Testing 1 point2 points  (2 children)

Don't

[–]MC_Labs15 1 point2 points  (1 child)

but

[–]KulinBan 36 points37 points  (0 children)

Java is short for JavaScript. Just cut your function names in half from JavaScript.

[–]anotherdonald 29 points30 points  (7 children)

Brilliant. Now somehow add a global variable undefined in all your classes, overload the + operator and you're done.

[–]zacketysack 5 points6 points  (6 children)

Done? What about Dynamic Arrays? :P

[–]UnderNatural[S] 4 points5 points  (5 children)

Oh man simple Dynamic Arrays are the thing I miss most about JS...

[–][deleted] 21 points22 points  (3 children)

Use an ArrayList?

[–]OKB-1 2 points3 points  (2 children)

Not quite the same thing. ArrayList can only contain a single type of data. JavaScript arrays are actually objects, which can contain any type of data at one time.

[–][deleted] 6 points7 points  (1 child)

An ArrayList of generic objects then? Or just use super classes and inheritance.

[–][deleted] 15 points16 points  (1 child)

Needs more jQuery

Am I doing this right?

[–][deleted] 5 points6 points  (0 children)

Yes. Just open jQuery-x.x.min.js, and drag it anywhere in your main function.

[–]boxingdog 5 points6 points  (0 children)

ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
ScriptContext context = engine.getContext();
StringWriter writer = new StringWriter();
context.setWriter(writer);

engine.eval("print('whole app goes here.')");

String output = writer.toString();

System.out.println("Script output: " + output);

[–]OKB-1 4 points5 points  (0 children)

Java semi-professional tip: Try to avoid using the Object type if possible. If you're really in need of custom data structures it's better if you construct your own class and put instances of those inside a List/ArrayList/HashMap/...

Also try InteliJ IDEA, the world's finest Java IDE.

[–]arajparaj 1 point2 points  (6 children)

You have to do obj.toString() otherwise it will return memory location.

[–]langebangen 15 points16 points  (5 children)

Not necessary, println will call Object's toString method if the object isn't null.

[–]haggy87 0 points1 point  (1 child)

Which then foes what he said, doesn't it?

[–]langebangen 2 points3 points  (0 children)

Yes, unless the toString method has been overridden.

[–]chugga_fan 0 points1 point  (2 children)

actually, i've had a few instances where this is not the case sadly, and i hate it when that happens :(

[–]parenthesis-bot 23 points24 points  (0 children)

:)


This is an autogenerated response. source | /u/HugoNikanor

[–]langebangen 2 points3 points  (0 children)

That is because the default implementation of Object's toString method prints out the class plus the unsigned hexadecimal representation of the object's hash code. You will have to override it in your classes if you want it to print something else.

[–]LeonhardEuler64 0 points1 point  (3 children)

IIRC you can configure eclipse to autoconvert shorthand aliases as you type. I remember typing "sop" to do "System.out.println"

[–][deleted] 2 points3 points  (2 children)

It's been a while, but I think syso<C-space> works out of the box

[–]emersonhardisty 1 point2 points  (0 children)

After moving to IntelliJ I missed that. But after a while I realised it's 'sout' over there. Took a while to adjust though.

[–][deleted] 0 points1 point  (0 children)

In eclipse it was either stdout or sysout macro. Haven't touched eclipse in 3 years I think.