What's the significant difference between Expressions vs Literals &amp;&amp; Expressions vs Statements in Java? I'm aware that an expression represents a simple value or a set of operations that produces a value. However, literals can also be a simple value which makes it a little confusing to make difference between them. Could smb explain the differences? Thanks in advance!
78505
I'm asking with regards to c#, but I assume its the same in most other languages.  Does anyone have a good definition of expressions and statements and what the differences are?
37382
I'm a C++ guy learning Java. I'm reading Effective Java and something confused me. It says never to write code like this:  String s = new String("silly");   Because it creates unnecessary String objects. But instead it should be written like this:  String s = "No longer silly";   Ok fine so far...However, given this class:  public final class CaseInsensitiveString {     private String s;     public CaseInsensitiveString(String s) {         if (s == null) {             throw new NullPointerException();         }         this.s = s;     }     :     : }  CaseInsensitiveString cis = new CaseInsensitiveString("Polish"); String s = "polish";    Why is the first statement ok? Shouldn't it be   CaseInsensitiveString cis = "Polish"; How do I make CaseInsensitiveString behave like String so the above statement is OK (with and without extending String)? What is it about String that makes it OK to just be able to pass it a literal like that? From my understanding there is no "copy constructor" concept in Java?
58651
Does anybody know if there is a way to evaluate a string containing boolean-logic at runtime? My logic, can only contain three operators and parenthesis (AND, OR, NOT). I can even make the string look like this: true &amp;&amp; false &amp;&amp; (true || !true)  I don't have the bandwidth to build a full-on parser... Any ideas?  PS: I saw some answers that pointed to the use of an API but I don't have access to use the Toolkit API in the environment this will get deployed.
13251
Do you think there is a big difference in for...in and for loops? What kind of "for" do you prefer to use and why?  Let's say we have an array of associative arrays:  var myArray = [{'key': 'value'}, {'key': 'value1'}];   So we can iterate:  for (var i = 0; i &lt; myArray.length; i++)   And:  for (var i in myArray)   I don't see a big difference. Are there any performance issues?
13804
I hope this qualifies as a programming question, as in any programming tutorial, you eventually come across 'foo' in the code examples. (yeah, right?)  what does 'foo' really mean?  If it is meant to mean nothing, when did it begin to be used so?
29396
I'm wondering whether there is a difference between these two expressions. I never know which one to use. Google seems to return the same amount of results for both, so I suppose there might be a difference.        What are the alternatives for this project?     What are the alternatives to this project?
9792
Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java.  And it's doubly puzzling because I used to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misinformation is a little disturbing...  Here's the problem I was given:  /* What is the output of the following program? */  public class Test {    public boolean equals( Test other ) {     System.out.println( "Inside of Test.equals" );     return false;   }    public static void main( String [] args ) {     Object t1 = new Test();     Object t2 = new Test();     Test t3 = new Test();     Object o1 = new Object();      int count = 0;     System.out.println( count++ );// prints 0     t1.equals( t2 ) ;     System.out.println( count++ );// prints 1     t1.equals( t3 );     System.out.println( count++ );// prints 2     t3.equals( o1 );     System.out.println( count++ );// prints 3     t3.equals(t3);     System.out.println( count++ );// prints 4     t3.equals(t2);   } }   I asserted that the output should have been two separate print statements from within the overridden equals() method: at t1.equals(t3) and t3.equals(t3).  The latter case is obvious enough, and with the former case, even though t1 has a reference of type Object, it is instantiated as type Test, so dynamic binding should call the overridden form of the method.  Apparently not.  My interviewer encouraged me to run the program myself, and lo and behold, there was only a single output from the overridden method: at the line t3.equals(t3).  My question then is, why?  As I mentioned already, even though t1 is a reference of type Object (so static binding would invoke Object's equals() method), dynamic binding should take care of invoking the most specific version of the method based on the instantiated type of the reference.  What am I missing?
31131
Assuming String a and b:  a += b a = a.concat(b)   Under the hood, are they the same thing?  Here is concat decompiled as reference. I'd like to be able to decompile the + operator as well to see what that does.  public String concat(String s) {      int i = s.length();     if (i == 0) {         return this;     }     else {         char ac[] = new char[count + i];         getChars(0, count, ac, 0);         s.getChars(0, i, ac, count);         return new String(0, count + i, ac);     } }
1308
What is the meaning of the notation $\exp(\text{expression})$ ?  I think that it's something of the form $a^\text{expression}$ but does it mean that the base $a=e$ or can it be any base?
91246
Kind of a weird question but where does the $\in$ symbol come from exactly and where do we imbue this symbol with any kind of meaning?  As far as I can tell it isn't a symbol that is part of the alphabet when it comes to propositional logic or first order logic. It just sort of pops out of nowhere when you get to something like the axioms of ZFC or set theory where we start saying things like $a \in S$ without really discussing what this symbol means or how you use it appropriately.   We all know it means "element of" but is there a more formal basis for its definition? Is there some kind of rule or axiom that shows how this syntax is meant to be used somewhere? I am coming at this from the perspective of syntax and semantics if that helps. Please note I am not asking about the history of the symbol $\in$.  For example let's say I start throwing around $a★b$ or $a★S$ in my syntax, you'd go, whoa, wait a second, I don't know what that symbol means or what we're allowed to do with it or how we're supposed to use it. Where would I "point you" to show these things?
80993
Before explaining my issue, I wanted to first explain what things do make sense to me. So, statements (used at the beginning of proofs) like &quot;Suppose $x$ is an integer&quot; or &quot;Assume $x$ is an integer&quot; make sense to me. The way I read them is like: &quot;Let's just pretend that the symbol $x$ happens to represent an integer&quot;. Statement (also used in proofs) like &quot;Let $x$ be 3&quot; or &quot;Let $x$ equal 3&quot; also make sense to me. The way I read them is like: &quot;Let's just temporarily name 3 with the symbol $x$. My issue comes with statements like &quot;Let $x$ be an integer&quot; or &quot;Let $x$ $\in$ $\mathbb{Z}$&quot;. I really do not know how I should intuitively interpret such a statement. I can't interpret it in the same way as like &quot;Let $x$ be 3&quot; because there is not a specific object being assigned like 3. Should I interpret it like how I interpret &quot;Suppose $x$ is an integer&quot;?  EDIT: So, from what I gathered from the responses, I think I understand now how I should think of &quot;Let $x$ be an integer&quot;. I could think of it as &quot;Assume a newly created symbol x happens to represent an integer&quot;. However, this can cause issues as then &quot;Let $x$ be an element of the empty set&quot; is also completely valid. Instead, I should not think of &quot;Let $x$ be an integer&quot; as an assumption, but an assignment/declaration, just like &quot;Let $x$ be 3&quot;. One tangible way to think about this is to imagine myself assigning the newly created symbol $x$ to an integer chosen in secret by a friend. With this mindset, $x$ is not assumed to be an integer - it is an integer. It is just unknown to me what integer it is. I hope this made sense to anybody with similar questions. If anyone thinks I have made an incorrect finding, please feel free to correct me.
8264
I have always used || (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: |. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable?
45363
I once learnt, that it is uncool to use $$, but why is that? Why does \[ not act as a abbreviation to \begin{align}? I noticed, that there is a difference, since one cannot use &amp; and \\ inside a block started with \[.
88167
I have come across several commands that use 2&gt;&amp;1 and 1&gt;&amp;2, but I quite can't get my head around the purpose of using it and when I should be using it.  What I understand  I know that 1 represents standard out and 2 represents standard error. I understand that 2&gt;&amp;1 combines the output of 2 to 1 and vice versa.  What I don't get   When should I be using it? What purpose does it serve?
41167
I am told that good developers can spot/utilize the difference between Null and False and 0 and all the other good "nothing" entities. What is the difference, specifically in PHP?  Does it have something to do with ===?
93
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
25568
How is parseInt() different from valueOf() ?   They appear to do exactly the same thing to me (also goes for parseFloat(), parseDouble(), parseLong() etc, how are they different from Long.valueOf(string) ?  Also, which one of these is preferable and used more often by convention?