|
Harold Ramis Drugs posted:Edit: Durf, totally solved my own problem. Don't use x == y to compare strings, use x.equals(y) Pffffffft, amateur. Yeah, that's definitely tripped me up a few times, but once you learn...it's so valuable. Always use the equals() methods to compare your strings, kiddies.
|
# ¿ Oct 29, 2011 22:43 |
|
|
# ¿ Apr 27, 2024 12:30 |
|
No Safe Word posted:Always use equals() to compare everything but primitive types And references .
|
# ¿ Oct 30, 2011 02:17 |
|
Sab669 posted:Why is equals() better than ==? I'm a huge noob at all of this... and in related news! The reason why I came to this thread. It's not a matter of being "better" than one another. You're simply comparing two different things. == is used to compare primitive types, or references. That's all it should be used for. The .equals() methods of classes is meant to compare the data within the object. So for example, you have two String objects (call them a and b), and both have "hello" in them. String has various data in it; it doesn't JUST contain the string "hello". In order to directly compare the strings, you need to call the .equals() method. So to properly compare a's "hello" and b's "hello", you call a.equals(b); Sab669 posted:Trying to write a try-catch statement to verify some input from the user. Unlike a try-catch from what I'm used to, this REQUIRES some sort of error to throw- I can't just print out my own error message. If you want to be terrible about it, you can just write: code:
code:
|
# ¿ Oct 31, 2011 01:08 |
|
tyang209 posted:Totally confused by this compiler error. I'm using DrJava and Eclipse and I'm pretty sure it's an error with something within Dr Java. Post the entire code, including your import statements. And for gods sake, use the [code] BBcode, man. EDIT: Also, on another note, you should probably do some error checking via a try/catch or calling hasNext(). pliable fucked around with this message at 10:08 on Nov 10, 2011 |
# ¿ Nov 10, 2011 09:57 |
|
rhag posted:Oh please, JavaFX is shiny, I'll give you that, but swing is where the real action takes place. And, personally, I don't see why is swing deprecated. What doesn't it have that you'd wish to see there? JavaFX is pushed by My only experience with Swing was with an Object Oriented class years ago and I remember thinking it was the biggest piece of poo poo ever. It seemed cumbersome, redundant...just a pain in the dick to write. Then again, I hardly write any GUI's, so...
|
# ¿ Apr 5, 2013 21:20 |
|
Tesseraction posted:WALL O DEBUGGIN' drat son, you're a kind coder. One hell of a post
|
# ¿ Apr 10, 2013 19:24 |
|
Onean posted:I'm looking to teach myself Java. The only programming I've ever done was some HTML and CSS about 7 years ago, which I picked up pretty quickly but have completely forgotten by now. After reading through some past pages, are Oracle's Java tutorials still the best place to start? I'm planning on putting together a Minecraft mod as a personal introduction to Java as I'm going back to school this fall for an IT degree, and I want a basic handle on Java before starting. I took a quick glance at some of the beginning lessons, but it looks like a pretty good start, especially for being free. Personally, I would learn this: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html before you learn the Object-oriented concepts. The page I linked teaches you more about basic mechanics of programming, which you need to know before anything about Object orientation. Also, oddly, the best way to go about it is immerse yourself in it. I suggest downloading BlueJ, as it also helps you learn what "classes" are (Object oriented stuff), and use that to code the examples in the tutorial.
|
# ¿ Apr 27, 2013 10:35 |
|
This is part of my ongoing confusion with Java's pass-by-value/reference dealio: Say I have an ArrayList of some object, and say that object implements Comparable so it can be sorted via Collections.sort(). Why the gently caress does that even work, if Java passes by value? For example: code:
|
# ¿ May 18, 2014 00:07 |
|
carry on then posted:e: it's a very subtle distinction, but it's one worth making. Yeah, and its subtlety still trips me up. But awesome, that clarifies...thank you much!
|
# ¿ May 18, 2014 00:19 |
|
Egorger Le Chef posted:I am taking a class in java and I have a few questions (I am not asking for homework help) Yeah like others said, one of the new features of Java 8 is closures, which, would be impressive if they ended up teaching it (I didn't even learn about closures until my upper division courses, so...). And call me spoiled but I can't program in Java without eclipse. There are too many useful features that make programming in Java much easier (eg: automatic building, code completion, etc). I only use Vim when programming in C (and sometimes Python, but I mostly use PyCharm for Python). ulmont posted:e;f,b. Thanks for the help anyway
|
# ¿ May 21, 2014 21:27 |
|
Zaphod42 posted:You don't have to use Eclipse, but in 2014 you do have to use an IDE. Vi and Emacs aren't IDEs. If you're really hardcore, you can use a simple text editor. I don't recommend it at all, but it's certainly possible and I've seen it done. I have a buddy that uses Vim for all his Python, and simply utilizes Vim tabs and splits to look at everything. You don't *have* to use an IDE, but it makes life much, MUCH easier. I'm also well aware that Vim and Emacs aren't IDEs .
|
# ¿ May 21, 2014 21:39 |
|
Kenishi posted:Java should be easier to learn than python in some respects because Java doesn't handle tuples and lists natively. Huh? ArrayList, LinkedList, Vector, Stack...
|
# ¿ Jul 14, 2014 09:31 |
|
Kenishi posted:Those are part of the Java standard library. If I have to import the thing to use it then its not natively part of the language. Plus I've always found the manipulation of lists/tuples in Python to be a lot easier than using the Java library ones. Oh, I consider anything part of the standard library to be "native", but I see what you mean. And yeah, I completely agree that lists/tuples in Python are way easier than Java. Before I used Python, I came from a C/Java background, and tuples blew the poo poo out of my mind. The ability to return tons of things as one tuple is sexy as gently caress
|
# ¿ Jul 14, 2014 22:33 |
|
Yhag posted:And this for the other one: Is there a particular reason why you're casting all those ints, storing them into ints, then passing those ints along to your setxx methods instead of just casting them and passing them straight? Like this: code:
pliable fucked around with this message at 11:26 on Sep 11, 2014 |
# ¿ Sep 11, 2014 10:03 |
|
|
# ¿ Apr 27, 2024 12:30 |
|
TheresaJayne posted:Well i have seen stuff like this in the past I'm a C coder as well and maybe I'm fortunate enough to have gone to a great university, but if any of my professors saw this after 101, they would fail us immediately.
|
# ¿ Sep 11, 2014 20:16 |