Tagged Questions
19
votes
4answers
809 views
Why do C# and Java use reference equality as the default for '=='?
I've been pondering for a while why Java and C# (and I'm sure other languages) default to reference equality for ==.
In the programming I do (which certainly is only a small subset of programming ...
4
votes
1answer
270 views
Is it possible to write a code without class methods, globals, and class variables? [closed]
I'm designing my own programming language for fun, and I'm thinking of making it fully Object-oriented (no statics, no globals, no class variables, no class methods), so I need to find a way to ...
19
votes
8answers
2k views
Why is String immutable in Java?
I couldn't understand the reason of it. I always use String class like other developers, but when I modify the value of it, I need to create new instance of String.
What might be the reason of ...
2
votes
6answers
767 views
Why is an interface in Java not allowed to have state? [closed]
There must be a good reason why Java designers didn't allow any state to be defined in interfaces . Can you please throw some light on this aspect of design decision ?
41
votes
10answers
2k views
I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?
My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. ...
5
votes
1answer
263 views
Why can't java generics be in arrays?
Why is it that when I try to make an array of ArrayLists: ArrayList<Integer>[] arr=new ArrayList<Integer>[40]; there is an error and java does not allow this?
Is there a reason related to ...
11
votes
2answers
855 views
Advantages and disadvantages of structuring all code via classes and compiling to classes (like Java)
Edit: my language allows for multiple inheritance, unlike Java.
I've started designing and developing my own programming language for educational, recreational, and potentially useful purposes.
At ...
3
votes
1answer
292 views
Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? [closed]
Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? Every single time I use BigIntegers, and many times I merely think about them, I wonder this.
What reason ...
9
votes
2answers
1k views
Why null pointer instead of class cast?
In Java:
int count = (Integer) null;
throws a java.lang.NullPointerException.
Why doesn't this throw a Class Cast Exception for ease in programmer understanding?
Why was this exception chosen ...
9
votes
5answers
6k views
Why is Python slower than Java but faster than PHP [closed]
I have many times seen various benchmarks that show how a bunch of languages perform on a given task.
Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder ...
10
votes
2answers
605 views
Why does a Java source file bear the name of the public class it contains?
I am a newbie learning Java. In Java every source file must contain a public class and that source file should have the same name as that public class. Moreover, no source file can contain two public ...
44
votes
12answers
4k views
Did the developers of Java consciously abandon RAII?
As a long-time C# programmer, I have recently come to learn more about the advantages of Resource Acquisition Is Initialization (RAII). In particular, I have discovered that the C# idiom:
using (var ...
15
votes
3answers
851 views
Java and .NET: Why different sorting algorithms are used by default?
Just wondering why Java and .NET Framework uses different sorting algorithm by default.
In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says:
In Java, the ...
6
votes
5answers
373 views
Java without implementation inheritance
In a recent video on Java, Joshua Bloch states at 4 minutes 20 seconds into the video:
And then there's inheritance, and that was a marketing necessity. You know, we can argue whether you really ...
5
votes
2answers
366 views
What do you think of an interpreter written in Java?
I am currently working on the implementation of a new programming language, for fun. I realize that most languages never become popular, but I still want the language to have a high-quality ...