Fun Stuff > CLIKC

A programming thread!

<< < (17/37) > >>

ankhtahr:
I had to resort to this, because I was getting a "cannot create a generic array".

In the end I gave up, because I finally need some sleep. I've been up for 27 hours now, and can't think straight.

Now the next upcoming exercise sheet is technical computer science, and that is the only lecture I seriously enjoy. Currently we're looking at a theoretical processor designed by our professor. This week our tasks are mostly implementing assembly-commands in micro operations. I enjoy this!

snalin:

--- Quote from: ankhtahr on 16 May 2014, 01:15 ---I had to resort to this, because I was getting a "cannot create a generic array".

--- End quote ---

Yup!

So, a generic is just a placeholder for a class that will be supplied later. This is implemented in Java (and C#) through type erasure - the type of the element will only be checked during compile time, and at runtime, no information about the class will be available.

The way to solve the problem is to use an ArrayList, as that will handle type checking for you.



--- Quote from: pwhodges on 16 May 2014, 00:13 ---I'm amused at all this Java shenanigans. When I had to write a cache of this sort (commercially, for money), I sketched it out in pseudocode and then implemented it in assembly language. As I recall it took about 300 bytes. The improvement in OS performance was similar to installing a SSD in modern terms.

--- End quote ---

Those were the days, huh? 300 bytes of of code is ~350 ASCII characters. That's not a lot of code.

Schwungrad:

--- Quote from: snalin on 11 May 2014, 04:23 ---This is a pretty good article about how things work: Java is Pass-by-Value, Dammit!

--- End quote ---
Urgs. Thanks for reminding me why I prefer C++ over Java.

cesium133:
Complaint: why, when compiling a program, do the libraries that need to be linked go after the file that requires them in the command line rather than before? I always think of them as prerequisites for the program, so when writing the command line I always end up putting them before and getting frustrated when it refuses to work...  :psyduck:

snalin:
In Java it would be:

javac -cp [stuff to put on class path like .jar or .class files] [.java source files]

So then it's before the sources. Or you could just set PATH temporarily.

In C++ (gcc), on the other hand, options are after the sources. I think. So then it's the other way around. So the answer to your question is language-dependent.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version