« first day (1097 days earlier)      last day (3847 days later) » 

12:50 AM
Why do people tag Android questions as also being Java? They know Android isn't Java right? And it happens we Java folk don't know the Android API?
I get Android is a lot like Java, so much so that Sun thought they could sue, but Android still isn't Java.
eh
 
 
2 hours later…
3:08 AM
@Radiodef I don't think there's any harm in it. It helps to taxonomize the questions, and in particular ensures the question goes to the appropriate audience. You're right, Android isn't Java; but it's a Java-based platform, and obviously many (although clearly not all) Java idioms apply in Android development. I for one develop in both environments, Java (Spring) during the day at my job, and Android at night as a hobby (so far).
I'm tuned in to both Android and Java chats most days. You could always just add Android to your list of ignored tags on StackOverflow, and then you'll only get the pure Java stuff :-).
 
 
1 hour later…
4:22 AM
It just always bugs me. Usually the questions are like "why does such and such not work with my List or some other Android class", also tagged Java, and it's like, how should I know? It's not Java. I see the languages are similar enough to warrant a shared tag if the question were actually relevant to Java but they almost never are. They are almost always Android-exclusive.
 
 
3 hours later…
7:14 AM
You can skip the java questions that also have android tag. I have answered some android questions despite never doing any android development, because the problem being a pure java issue (the asking person does not necessarily know that). I don't think android is different from the myriad frameworks in that sense. A spring/jsf/junit... question is typically dependent on those non standard libraries the same way.
 
 
4 hours later…
11:41 AM
ALWAYS INACTIVE ,,,
 
 
4 hours later…
3:32 PM
@Radiodef Technically Android is not Java, you're right; but only if you mean that it's not standard Java; it uses a different type of virtual machine, and different standard libraries, but it's still a Java implementation. Developers are not programming in "Android", they're programming in Java, using the Android libraries.
@kiheru's point is good - it's like a framework, although it's arguably more specialized than something like Spring. But I still think it's appropriate to tag Android questions with Java. Maybe you should bring this up in Meta - if the community disagrees with me, I'll eat my words :-)
 
3:55 PM
Here's one meta q/a about just the opposite - a Java question that shouldn't have been tagged with Android meta.stackoverflow.com/questions/112790/…
 
4:51 PM
Well maybe I'm the dumb one, I thought Android was merely modeled after Java? That is why Sun sued Google, because Sun claimed Google "copied" their API without permission.
Also it's not that Android questions tagged Java piss me off or anything, I just don't know what people that do that really expect. And of course @kiheru is right that sometimes indeed there is an Android question that can be answered by Java-only types.
Since I assume the implementations could be completely different behind the scenes I don't feel comfortable answering technical questions. But again maybe I am wrong and Android is actually identical (or nearly identical) to regular Java.
I admit I basically don't know anything about Android except the stuff I occasionally come across so could be I am just misguided and tagging Android as Java and vice versa makes more sense than I am thinking.
 
Yea the stuff about Oracle vs Android I'm not really sure what was going on there. Supposedly Oracle was gung-ho about Google using Java at first. Then they freaked out when it was actually implemented? Something like that. Some think maybe Google just figured they'd go for it and deal with the repercussions. Kind of goes against their "don't be evil" philosophy!
 
5:07 PM
That's weird. I know ultimately Google won out since the courts ruled that you can't copyright API, only the underlying code implementation.
 
Wow that's a pretty significant ruling.
API is pretty much "the" product
 
Oh OK well according to Wikipedia at least, initially what happened is Google worked with Sun on implementing Java in Android and Google decided to release Android with some Java SE API without a licensing agreement for it.
They were in talks about partnering or somesuch when Oracle bought Sun.
So it would seem Oracle had different ideas.
 
Ahh Oracle wanted their cut on the licensing
Makes sense
 
The official ruling was "So long as the specific code used to implement a method is different, anyone is free under the Copyright Act to write his or her own code to carry out exactly the same function or specification of any methods used in the Java API. It does not matter that the declaration or method header lines are identical."
And you're right it is a pretty interesting ruling.
Incidentally I see now Android is basically a verbatim Java implementation which I didn't know.
 
Posted in the Android forum a few minutes ago: i.imgur.com/dlw4IZV.jpg
lol
 
5:16 PM
ahaha I'll remember that. Programming communism.
 
5:31 PM
Hey guys, I've got a hw question (which I've attempted!), but I'm too scared to ask in stack in case of downvotes , can any1 help me here? it's regarding java.lang.ArrayIndexOutOfBoundsException: 0 error
 
@Eggy sure
It seems your array is empty
 
Sorry, I'm not able to open pastebin, would you please use a gist?
 
one sec plz
 
Yea the array is empty
 
5:36 PM
I understand that, but how do I link it properly so it's not empty. and Omar, do u mean github?
 
instead of double[] A = {};
do double[] A = new double[n];
(you'll either have to make an n variable or replace n with a number, for example, 3)
 
@AaronBlenkush is right
 
int n = 0; still same error :/
int n = 0;
double[] A = new double[3];
i mean
 
Well make n > 0
Otherwise what you're doing is creating a zero-length array.
When you get an element from an array like A[0], it's actually getting the 1st element. But there is no 1st element in a zero-length array
 
right
I'm not trying to be annoying, but it's still giving same error.
int n = 3;
double[] A = new double[n];
 
5:44 PM
K hang on
 
sorry
 
Don't you have the full stack-trace?
 
Your outer for loop is going from 0 to 9. So you need to make n = 10.
(0 to 9) is ten distinct numbers, not 3 :-)
Make sense?
 
yes
 
you could use the array length
 
5:48 PM
just a quick question, am I following the pseudo correctly? cuz I've done another version which doesnt follow the pseudo and it works
 
instead of a hardcoded value
it seems you're not
you're not following the loop condition
actually you're hardcoding the condition
For i = 0 to n-1
and you have
for (int i = 0; i<10; i++)
 
ohhhhhh]
guys
i love u
 
xD
 
thank u for ur help!
 
5:52 PM
You're welcome
 
6:49 PM
Hello everyone. Just using this chat for the first time. Anyone out to help me out with some teething Struts 2 questions?
 
7:33 PM
@nwaomachux are you still here?
 
 
2 hours later…
9:08 PM
1
Q: Java running main method of other class, when JButton is pressed

AdrianI am trying to develop a JFrame which has two buttons that would let me to call the main method of other classes. The first try was to put it directly into the actionPerformed of each button, this will cause the JFrame of the other class to open but showing only the title of it and not showing an...

Guess I should not have been condescending.
 
it is possible to have multiple mains, only one of them can serve as the entry point at a time though. it also is possible to call main() elsewhere from the program, but I would not recommend that. That question is quite similar to one I answered earlier today: stackoverflow.com/questions/19564219/…
 
Yeah, I know, I am referring to the fact that the chosen answer doesn't actually correct the problem.
Which is to not bother creating the GUI on the EDT, instead just create a new Thread every time you want to do something.
 
yeah :-/ the accepted answer is rather dangerous
depends on what ClientMain.main() does. If it does not use swing then it's not a problem
 
9:27 PM
According to the OP all the program does is create JFrames and display them.
 
9:41 PM
I can't find a clear explanation of ClientMain in the post. I'm getting too sleepy to think though so maybe I just missed it.
 
He says "this will cause the JFrame of the other class to open but showing only the title of it and not showing any contents of the JPanel additionally freezing the program" which seems to imply the other class creates a JFrame and displays it.
 
okay. I'm tired :-D
 
Honestly it's just pretty hard to tell what it does.
 
10:02 PM
Hello!
I have a question so if there is anyone here who can answer that'd be great!
 
I am here and I can try
 
I am working on a game in Java and I know using public variables is usually not the best idea for whatever reasons but in this case would it be the right thing to do? (following)
Its a player object
That has variables like public int money=0;
in this case would it be ok to do public?
or even if its an object should it still use get and set methods?
 
Generally speaking it depends on what you are using the field for
 
There's no hard and fast rule for variable scope
 
Yeah
 
10:05 PM
so u think it would be fine in this case?
 
Maybe this sounds stupid but honestly what it really comes down to if it's just your own code is whether you think you will accidentally change it when you meant not to.
private fields matter more when you are for example really trying to make the field immutable
 
hm interesting is that why we it is bad practice to use public variables?
 
like in the case of the Java String which internally I'm sure holds a char[] and the reason String is immutable is that it has no setters, only methods that return values from the array
 
making a field private means that no other classes can change it unless they go through the mutators or accessors (set or get)
If you want it to be readonly, you could omit the mutator
 
so its also a way of stopping people from messing things up in the program?
 
10:07 PM
Yes. And to an extent it also forces you as the programmer to think about what you are doing when you make a call to set the variable
Yes @ Aaron's comment I mean
 
Ok that makes sense
 
Yes. and stopping yourself from messing things up
;-)
 
I am kind of confused still on the messing up part, how can one mess up their own work because they used public?
 
It's a good question
 
is it just neater to use set and getters?
 
10:09 PM
Just means you accidentally changed the field when you meant not to or should not have. IE you made a boo-boo
Maybe you've been up coding for 14 hours straight and you meant to change field instead of object.field or who knows what
 
Oh ok so like if an object has the same variable
u dont want to get them mixed up?
 
One good reason to use accessor methods is that then it's easier to change implementation later. You might at first have an addMoney() method that just adds. But later decide that passing certain amount of money triggers an achievement. If you have it as a public field you'll need to check all accesses and keep remembering to check them every time you use the public field
 
It's good for future development too. You might decide later that you need to trigger some validation or other logic when money is get or set
 
And yeah generally the Java paradigm is to use setters and getters. So much that there is a standard kind of object called a "Bean" that private fields are a requisite of.
 
so especially if I wanted people to be able to make plugins and such for my program setters and getters would be quite important since thats the standard way to go?
 
10:11 PM
yes
 
@AaronBlenkush also right. Maybe you want to update the GUI or something every time money is changed for example.
 
Standards are important for collaboration, and for providing a clear API
Developers expect that properties are get/set through get/set methods
 
now that I think about it, the money JLabel will have to be updated when the money changes, so a setMoney or addMoney would be quite important :)
 
Taking a look at the Java API generally exemplifies that. There are basically not a whole lot of fields that are public except constant-type static final fields.
yep
Even though setText is only an extra line, adding a setMoney method saves you a line of code everywhere you want to change the money, even if you are making the change inside the player class.
 
Also, what are you guys thoughts on using something like net beans to quickly setup a GUI program? I have never done it because it seems it will make variables and such quite messy.
 
10:15 PM
I've always programmed my GUI by hand too. Guess it depends on what your GUI is like and what you're using it for.
 
I do my layouts manually too
 
Its more fun doing it manually :)
 
high-five
 
I guess it would be ok to use if it were a very quick and small program, but then it must not be a very good program. I think I'll just stick with manual then. I wasn't sure if I was out of the ordinary or not so.
 
Not sure how a visual editor will handle stuff like GridBagLayout and lots of nested panels.
Swing is also very geared towards dynamic behavior of GUI over absolute positioning and I really think behavior is easier to specify in code. Though honestly I have never used a GUI builder for Java so I can't really say. I just feel like I actually know what's going on doing it myself.
 
10:19 PM
Yup same.
 
manual seems to be what the big names at swing tag usually do. at least I have never seen any of them recommend using a gui builder (and several times seen them recommend against using one, at least until having a good grasp of manual use)
 
I'd expect using a GUI builder you will still end up eventually having to go in and change the code yourself somewhere.
 
Yes it would just be much more complicated
and nearly impossible by the time ur program gets to a point of largness
 
I've only used a GUI builder-type feature back when I started programming on Visual Basic and they let you specify all absolute pixel sizes.
 
GroupLayout is supposedly well suited for gui builder (manual use is for those who think that GridBagLayout is too simple and easy to use)
 
10:23 PM
Got to admit I've never actually used GroupLayout. What does it do that GridBagLayout can't?
 
Probably nothing, other than working better with gui builders. That's what it was made for
 
Do u guys know how u would setup a program so people could make plugins for it?
actually nvm that
 
Looking at it seems like it's just like GridBagLayout but there's no grid, instead it's all glued together like BoxLayout.
 
I dont even know how to make a custom listener so
Actually I do I thought it though, quite simple
 
Well sounds like you are making a game, by plugin you mean like a mod? That's actually an interesting question I don't know the answer to. Other than using JNI and doing the plugins in something like C++
 
10:28 PM
I gosh, getting into combining languages
I never have understood that
 
But I thought Java can actually do package imports at runtime.
 
How is it even possible to use 2 languages for one thing?
 
JNI is pretty nutty actually. You basically are just programming in 2 or 3 languages.
 
0.o
U could call C++ methods on a java object?
Idk C++ very well yet no way I could even understand how they would work together yet
 
Well what JNI is is the Java Native Interface. Basically you can program something like a DLL or on Mac called a dylib which is a big library in C, C++, Objective-C, etc. Then you can access those functions inside Java and vice versa
 
10:30 PM
hm interesting
 
It lets Java do all kinds of things Java can't normally do, like you could program DirectX in C++ and access those functions inside Java
I use JNI for audio playback because I don't like Java Sound.
The catch is it means you have to write platform-specific parts of the program.
But you can also think of it the other way around and then JNI means you can write platform-independent parts of the program (GUI and anything else you want in Java).
 
Wow, I can't wait till I can program fluently in many more languages
 
Java was written with C
 
and C was written in binary?
 
And in some cases JNI is more or less actually the only option, audio playback being one of those. Java Sound only does some basic formats so it is much more convenient to write sound playback in native.
 
10:33 PM
maybe assembly
But not binary ^_^
 
so its like a line of OOP creating eachother?
isnt binary the base language of computers? Like 0000202001 and all that?
 
for plugins in java it's possible to load .class files at runtime, and instantiate stuff there using reflection
 
Generally assembly is the bottom-line of programming. In assembly you are doing only low-level stuff like manipulating memory addreses.
 
C novadays is written in C
 
which makes no sense...
 
10:36 PM
Yo dawg I heard you like C
 
(actually, the implementations are starting to use C++)
 
a language written in its own language?
 
that's quite usual
 
What was the first language for computers?
 
That's probably a pretty gray area
Binary is not a "language"
 
10:38 PM
Wait then what is it? Isn't it something you can program in?
 
Jeremy I think by binary you mean what is usually referred to as machine code which is an instruction set in binary codes
 
it needs a compiler, which is not necessarily the same compiler as is being compiled (it's also possible to have an implementation for a simple subset of a langauge that is used for bootstrapping the initial implementation)
 
"Binary" is just the representation of information. Binary means in two. On/off, true/false, 1/0, etc.
 
I wonder what happens at the very base of a computer though
 
Technically speaking all computer languages are binary because all data on a computer is stored in a binary representation. : )
 
10:40 PM
haha true
 
like before prorgamming how does the programming, pixels on a screen that appear to us as words and make sense, how do they do anything
 
Magic
 
Transistors!
 
like what is physically happening behind all of that?
 
10:41 PM
oh yeah
 
I wana know...
 
Semiconductors
 
"What happens at the very base" can get deep: plus.google.com/112218872649456413744/posts/dfydM2Cnepe
 
^that's awesome
 
Also Louis CK "Why": google.com/…
 
10:43 PM
im reading and watching this is very interesting
 
PNTSNDLTN
 
um
this is just a comedian dude...
 
lol Radiodef
 
but it's great Jeremy
 
Jeremy - the skit involves his daughter asking "Why" over and over again until he gets down to the very nature of reality, pretty deep (and funny)
what does he say, it's a deconstruction of self?
 
10:45 PM
yeah it looks like that's actually the 2 skits combined
 
ah i just google-copy-pasted
 
the "Why" skit starts at about 6:30, though I gotta say the preceding ones are some of my favorites too
"it's an insane deconstruction" is the quote ehehe
 
hahah yes!
 
Gets so freaking complicated... Apparently a single person cannot understand it all himself it just has to be different people specialized in their own certain area. Very interesting.
And apparently understanding what is actually happening is nearly impossible
 
Basically all of human civilization works that way.
 
10:59 PM
I don't understand how I managed to get my underwear on this morning.
 
lol.
Next time you see a neurobiologist ask them how you do that.
 
Supposedly they just figgered why we need sleep -
Garbage collection
Little thingamajigs carry away waste via the cerebrospinal fluid or something like that.
Now that's what I call a "memory leak"!
 
Weird I always thought they knew.
 
You'd think so. Apparently they didn't :-/
 
^ if you click the link there is a video that starts playing so don't tab away while it loads and be surprised like I did
 
11:06 PM
 
aha
 
11:21 PM
lol...apparently today's xkcd is actually an understatement: telegraph.co.uk/finance/newsbysector/retailandconsumer/8360246/…
supposedly there have been 40 billion lego people manufactured to date
 
Have u guys gotten into game development with java at all?
 
nope just boring business stuff
 
What fun is it to be under someone, when you can be the one over others? :)
You should start a business then you have freedom
 
What does it mean when someone says sprite based game development?
I have heard the term sprite in programming before but what is it
 
11:34 PM
Personally programming is more like an overgrown hobby of mine but I can say I wouldn't mind doing it for somebody else at all since I just like doing it.
 
I've only been programming professionally for a few years. It used to be an overgrown hobby for me as well. :-)
 
A sprite is a 2D texture image, specifically one that's not wrapped on to a 3D model
 
Sprites = Pokemon (old-school Gameboy versions)
 
yes and like Doom which was "3D" but used sprites
 
Or Final Fantasy, Zelda etc
right
 
11:36 PM
So I would say sprite based game development is game development without 3D models
A lot of games that are 3D also use sprites for certain things, like some visual effects where the angle doesn't matter. You might see flame on a torch and it's a sprite, stuff like that.
Actually Wikipedia has a pretty huge article on sprites: en.wikipedia.org/wiki/Sprite_(computer_graphics)
 
Also there are CSS sprites you'll hear about in web design. You have all your icons in one big image. And then you grab each one as you need with CSS background-image positioning.
 
IIRC the visual appearance of ye old MissingNo bug is an error due to reading incorrect memory addresses as the sprite.
 
Oh ok makes sense thanks
Any idea on what a good book would be to begin in game development for Java?
 
Actually the whole MissingNo bug is pretty interesting, I found a pretty fascinating page that explained it in great technical detail. It's a big mess of lookup tables and pointers to pointers. Now I can't find the link, apparently I didn't bookmark it for some stupid reason.
Not sure about a book specifically on Java. Java isn't typically used for games, though I know there are some YouTube series about it. Really any game development book ought to apply, you will just need to become very familiar with using Graphics2D.
And there is JavaFX as well though I don't know a whole lot about it and my impression is that it is just Graphics2D with more features, still not like DirectX or OpenGL.
Direct3D I should say, DX encapsulates all kinds of things.
Personally my advice is if you really want to learn game development, something you can do is just buy a license to an engine and then you don't have to learn from the ground up.
Most game engines sell indie licenses for cheaper, I know Torque sells an indie license for like $100. I don't know about Unreal and other major engines. The benefit is that you basically get a whole game that you can more or less play around with. The source code is available to you if you want to add to it or learn from it but you don't have to mess with it if you don't want to.
For $100 you get a hell of a sandbox.
Both TorqueScript and UnrealScript are very similar to Java. My impression is UnrealScript is nearly identical.
 
11:54 PM
{} languages?
 
Yeah.
Both are object-oriented and the rules for UnrealScript are very similar to Java. They make it so you don't even really have to touch engine code unless you really really want to. You just make entire games in script.
 

« first day (1097 days earlier)      last day (3847 days later) »