what is wrong with my return statement??????
the compiler give me the following error :
D:\javafiles\Image Matching Algorithm\ImageMatchingAlgorithm.java:15: missing return statement
}
^
D:\javafiles\Image Matching Algorithm\ImageMatchingAlgorithm.java:21: missing return statement
}
^
2 errors
Process completed.
Code java:
import java.util.*;
import java.lang.*;
public class ImageMatchingAlgorithm
{
int swaped1;
int swaped2;
int isolated;
public boolean hasReversed(int mw_axis, int sw_axis)
{
if(sw_axis > mw_axis)
return true;
}
public boolean isTangible (int mw_axis, int sw_axis)
{
if (mw_axis == sw_axis)
return true;
}
public void doIsolate(int mw_axis)
{
isolated=mw_axis-1;
}
public int getIsolated()
{
return isolated;
}
public void doSwap(int coor1, int coor2)
{
swaped1=coor2;
swaped2=coor1;
}
public int getMWSwapedDim()
{
return swaped1;
}
public int getSWSwapedDim()
{
return swaped2;
}
public static void main (String[] args)
{
Scanner readDim = new Scanner(System.in);
int scanx;
int scany;
ImageMatchingAlgorithm Obj = new ImageMatchingAlgorithm();
MainWindow mw = new MainWindow();
SubWindow sw = new SubWindow();
System.out.print("Dimension of MW X axis:");
scanx=readDim.nextInt();
mw.setDimX(scanx);
System.out.print("Dimension of MW Y axis:");
scany=readDim.nextInt();
mw.setDimY(scany);
System.out.print("Dimension of SW X axis:");
scanx=readDim.nextInt();
sw.setDimX(scanx);
System.out.print("Dimension of SW Y axis:");
scany=readDim.nextInt();
sw.setDimY(scany);
if (Obj.hasReversed(mw.getDimX(), sw.getDimX()) )
{
Obj.doSwap(mw.getDimX(), sw.getDimX());
mw.setDimX(Obj.getMWSwapedDim());
sw.setDimX(Obj.getSWSwapedDim());
}
if (Obj.isTangible(mw.getDimX(), sw.getDimX()))
{
Obj.doIsolate(mw.getDimX());
sw.setDimX(Obj.getIsolated());
}
if (Obj.hasReversed(mw.getDimY(), sw.getDimY()) )
{
Obj.doSwap(mw.getDimY(), sw.getDimY());
mw.setDimY(Obj.getMWSwapedDim());
sw.setDimY(Obj.getSWSwapedDim());
}
if (Obj.isTangible(mw.getDimY(), sw.getDimY()))
{
Obj.doIsolate(mw.getDimY());
sw.setDimY(Obj.getIsolated());
}
}
}
Re: what is wrong with my return statement??????
The problem is exactly what the compiler describes..missing return. For both functions, the code returns true under a particular condition, but it also needs to return a value of that condition is not met
Code :
public boolean conditional(){
if(true){
return true;
}
return false;//returns a value if the above condition is not met.
}
Re: what is wrong with my return statement??????
Re: what is wrong with my return statement??????
many thanks. it works properly now.
Prima!!!!!!!