src.samples.java.ex.ITC_Sample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sb-contrib Show documentation
Show all versions of sb-contrib Show documentation
An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.
The newest version!
package ex;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
@SuppressWarnings("all")
public class ITC_Sample {
class A {
}
class B extends A {
}
class C extends A {
}
public String testOthers(List l) {
if (l instanceof ArrayList)
return (String) ((ArrayList) l).remove(0);
else if (l instanceof LinkedList)
return (String) ((LinkedList) l).removeFirst();
else if (l instanceof Vector)
return (String) ((Vector) l).remove(0);
else
return null;
}
public String testMine(A a) {
if (a instanceof B)
return "Yes";
else if (a instanceof C)
return "No";
else
return "Unknown";
}
}