- a generic class, should be restricted for use
Array List
.
.
.
tmpCards.add(anotherCard);
.
.
.
Card[] allCards = new Card[tmpCards.size()]
allCards= tmpCards.toArray(allCards);
How to check if Equal?
String s1 = "abc"
String s2 = "abc"
'==' tests equality of reference
if (s1 == s2) or s1.equals(s2)
System.out.println ("equal")
else
System.out.println("not equal")
the answer is equal!
even
String s3 = "a" + "b" + "c"
if (s1==s3) .....
will be equal
but
String s4 ;
s4 = "b";
s4 = "a" + s4;
s4 += "c" ;
if (s1 == s4)....
NO it is not equal
s1.equals(s4)
Yes it is equal!
Recursion
GNU ::= GNU is not Unix
"recursive acronym"
----------------
name list ::= name, namelist | name
Fibonacci Numbers
F(0) = 0
F (1) = 1
F(k) = F(k-1) + F(k-2)
int fibonacci (int k) {
if (k==0) return(0);
if(k==1) return(1);
return(fibonacci(k-1) + fibonacci(k-2));
}
No comments:
Post a Comment