Академический Документы
Профессиональный Документы
Культура Документы
public class dd
{
static Runnable r=new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try
{
Thread.sleep(1000);
}catch (InterruptedException e) {
// TODO: handle exception
System.out.println("interrupted");
}
System.out.println("ran");
}
};
public static void main(String args[]) throws InterruptedException
{
Thread t=new Thread(r);
t.start();
System.out.println("started");
t.sleep(2000);
System.out.println("interrupting");
t.interrupt();
System.out.println("ended");
}
}
-------------------------------------------public class dd
{
public static void go(short n)
{
System.out.println("short");
}
public static void go(Short n)
{
System.out.println("Short");
}
public static void go(Long n)
{
System.out.println("Long");
}
public static void main(String args[]) throws InterruptedException
{
Short y=6;
int z=7;
go(y);
go(z);
}
}compilation fails
----------------------------------------------------------------------public class dd
{
public static void main(String args[]) throws InterruptedException
{
class A
{
void process() throws Exception
{
throw new Exception();
}
}
class dd extends A
{
void process()
{
System.out.println("Go in Goban");
}
public static void main(String args[])
{
new dd().process();
}
}
-----------------------------------------------------------interface Foo
{
int bar();
}
public class dd
{
class a implements Foo
{
public int bar()
{
return 1;
}
}
public int fubar(Foo foo)
{
return foo.bar();
}
public void testfoo()
{
class a implements Foo
{
public int bar()
{
return 2;
}
}
System.out.println(fubar(new a()));
}
public static void main(String args[])
{
new dd().testfoo();
}
}
---------------------------------------------------------------class c
{
public String value;
public String getvalue()
{
void
void
void
void
int long
-----------------------------------------import java.util.Scanner;
public class dd {
public static void main(String [] args) {
Scanner sc=new Scanner("one,5,true,3,true,6,7,false");
sc.useDelimiter(",");
while(sc.hasNext())
{
if(sc.hasNextBoolean())
{
System.out.println(sc.nextBoolean());
}
else
sc.next()
;
}
}
----------------------------------------------------------------------enum x{
Earth,wind,
Fire{
public String info(){return "hot";}
};
public String info()
{
return "element";
}
}
---------------------------------------------------------------------public class dd {
private HashMap<String, Integer> map=new HashMap<String, Integer
>();
public void put(String name,int value)
{
map.put(name, value);
}
public Set<String> gn()
{
return map.keySet();
}
public static void main(String [] args) {
}
}
----------------------------------------------------------------------------------