Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: what is wrong with my return statement??????

  1. #1
    Member
    Join Date
    Nov 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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.

     
    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());
    		                      }	
     
     
    	}
    }
    Last edited by amr; December 13th, 2010 at 07:49 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default 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
    public boolean conditional(){
        if(true){
            return true;
        }
        return false;//returns a value if the above condition is not met. 
    }

  3. #3
    Member
    Join Date
    Nov 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: what is wrong with my return statement??????

    many thanks.
    Prima

  4. #4
    Member
    Join Date
    Nov 2010
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: what is wrong with my return statement??????

    many thanks. it works properly now.
    Prima!!!!!!!

Similar Threads

  1. Help - Return to menu screen
    By throzen in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 29th, 2009, 01:44 PM
  2. tax return program..help finish please!!
    By dscrudato21xo in forum Loops & Control Statements
    Replies: 2
    Last Post: November 5th, 2009, 03:23 PM
  3. Missing Return Statement in If-elseIf-else
    By chronoz13 in forum Loops & Control Statements
    Replies: 2
    Last Post: October 12th, 2009, 07:01 AM
  4. Prime number generator program missing return statement
    By 03EVOAWD in forum What's Wrong With My Code?
    Replies: 13
    Last Post: September 10th, 2009, 09:17 AM
  5. Error of "Class has no return statement"
    By mdstrauss in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 2nd, 2009, 12:00 PM