A friend of mine and I are taking an external computer science test. While studying the review it has become apparent that some of the syntax presented is quite unfamiliar.
Here are a few examples: Stack<Integer> s = new Stack<Integer>();
For this line of code what exactly is the purpose of "<Integer>"?
Does this make it so Stack only returns objects of type Integer?
A question on the review:
"Which of these regular expressions matches both "aggie" and "longhorn". but not "sooner"?
a. [als].*[enr]
b. .*g.*
c. .....(orn)+
d. [^sooner]
The answer sheet says the answer is b. However, I can only make assumptions as to why, and I would like to know if the other answers are valid in syntax and what exactly the symbols mean. What would be helpful are keywords that I could use to perform a search that returns valid results.
Finally, how is a colon to be used with a for loop.
For example:
for(int a : array)
{
if(a>max) max = a;
}
It appears as if a will take on various values from array. But, I believe I have seen the colon used in a for loop where the realtionship didn't appear as obvious.
What possibilities are there for using a colon in a loop? Is there a name for this?
That seems to sum my questions up. I don't expect explanations of these things (although that would be nice). But I would particularly appreciate it, if anyone was able to give names to these items so I could find more information with that.