In the Following Simple programs im getting a common error. missing return statement. Please help me find the repeated error committed by me.
program 1:
import java.io.*;
class jugal
{
int i,j;
/* jugal(int i,int j)
{
this.i=i;
this.j=j;
}*/
public int disp(int i,int j)
{
this.i=i;
this.j=j;
return i+j;
}
}
class sample
{
public static Void main(String a1[])
{
jugal j1=new jugal();
System.out.println(j1.disp(5,5));
int a=Integer.parseInt(a1[0]);
int b=Integer.parseInt(a1[1]);
jugal j2=new jugal();
int c=j2.disp(a,b);
System.out.println("show" +c);
}
}
program 2:
interface example
{
final int a=5;
Void show();
}
class jugal implements example
{
public Void show()
{
System.out.println(a*a);
}
}
class sample1
{
public static Void main(String a1[])
{
jugal j1=new jugal();
j1.show();
}
}
program 3:
class jugal implements Runnable
{
Thread t;
jugal()
{
t=new Thread(this,"demo");
System.out.println(t);
t.start();
}
public Void run()
{
try
{
for(int i=1;i<10;i--);
{
System.out.println(i);
Thread.sleep(500);
}
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
class sample2
{
public static Void main(String a[])
{
new jugal();
try
{
for(int i=1;i<10;i--);
{
System.out.println(i);
Thread.sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
program 4:
import java.util.*;
public class sample5
{
public static Void main(String a[])
{
int c[]={5,7,1,3,2};
Set<Integer> s=new HashSet<Integer>();
for(int i=0;i<5;i++)
{
s.add(c[i]);
}
System.out.println(s);
TreeSet ss=new TreeSet<Integer>(s);
System.out.println(ss.first());
System.out.println(ss.last());
}
}
program 5:
import java.util.*;
public class sample6
{
public static Void main(String a[])
{
int c[]={4,6,2,1,9};
List<Integer> l=new ArrayList<Integer>();
for(int i=0;i<5;i++)
{
l.add(c[i]);
}
System.out.println(c);
LinkedList<Integer> l1=new LinkedList<Integer>(l);
for(int i=0;i<5;i++)
{
l1.addFirst(c[i]);
}
System.out.println(l1.removeLast());
}
}
program 6:
import java.util.*;
public class sample7
{
public static Void main(String a[])
{
String s[]={"sun","mon","tues","wed","thrus"};
Map m=new HashMap();
for(int i=0;i<5;i++)
{
m.put(i,s[i]);
}
TreeMap t=new TreeMap(m);
System.out.println(t.keySet());
System.out.println(t.firstkey()+" value: "+t.get(t.firstKey()));
System.out.println(t.lastKey()+" "+t.get(t.lastKey()));
System.out.println(t.remove(t.lastkey()));
System.out.println(t.values());
System.out.println(t.keySet());
}
}
program 7:
import java.util.Vector;
import java.util.Enumeration;
class sample8
{
public static Void main(String a[])
{
Vector<Object> v=new Vector<Object>();
int p=20;
Integer i=new Integer(20);
String s=new String("Jugal");
v.add(i);
v.add(p);
v.add(s);
System.out.println(v);
v.add(2,new Integer(10));
System.out.println(v);
System.out.println(v.elementAt(2));
System.out.println(v.firstElement());
System.out.println(v.lastElement());
v.removeElementAt(2);
System.out.println(v);
System.out.println(v.firstElement());
System.out.println(v.lastElement());
Enumeration e=v.elements();
while(e.hasMoreElements())
{
System.out.println(e.nextElement());
}
}
}