Paredes Be

Greenhorn
+ Follow
since Sep 19, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paredes Be

Remember bro., The static�s blocks are readen first after the constructors. All the static�s blocks must be readen and next all the constructors will be.

Look this example and the numbers.

class CuerposEstaticos {
public static void main (String[] args){
B2 b2 = new B2(); //0
}
}

class A1 extends X3 {
A1() {
System.out.println("cA1"); //5

}
static {
System.out.println("sA1"); //2
}
}

class B2 extends A1{
B2() {
System.out.println("cB2");//6
}
static {
System.out.println("sB2"); //3
}
}

class X3 {
X3() {
System.out.println("cX1"); //4
}
static {
System.out.println("sX1"); //1
}
}
Hi guys,
Somebody could I tell me, Why in the marked line, cause a compile error "cannot find symbol" if l tends to be a List and it has the add
method?.

import java.util.*;
class Shape{
}
class Rect extends Shape{
}
class Circle extends Shape{
}
class ShadedRect extends Rect{
}
class Generics2{
public static void add(List<? extends Shape> l,int pos, Rect r){
l.add(pos, r); // Compile Error in this line.Why?
}
public static void main(String args[]){
List<ShadedRect> l = new LinkedList<ShadedRect>();
add( l,0, new ShadedRect() );
}
}