6 Replies - 649 Views - Last Post: 19 July 2009 - 03:18 PM Rate Topic: -----

#1 luron31  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 19-July 09

Missing Return Statement

Post icon  Posted 19 July 2009 - 02:43 PM

Hello, I am getting an error on my command prompt
"missing return statement" at line 23 which is
public int getSize()
	{
		actualSize = CellPhoneBook.length - 1;
		System.out.println("The size of the phone book is:" + actualSize);	
		}


this is the whole code



public class CellPhoneBook
{
	private int maxsize;
	String [][]CellPhoneBook;
	int actualSize;

	public CellPhoneBook(int maxsize)
	{
		this.maxsize=maxsize;
		if (CellPhoneBook.length>=maxsize+1);
		System.out.println("error in Phone Book size");
	}

	public boolean addEntry(CellPhoneBookEntry entry)
	{
		return false; // replace this line with your code
	}

	public int getSize()
	{
		actualSize = CellPhoneBook.length - 1;
		System.out.println("The size of the phone book is:" + actualSize);	
		}

	public CellPhoneBookEntry getEntry(int i)
	{
		return null; // replace this line with your code
	}
	
	public String lookupCellNumber(String name)
	{
		return null; // replace this line with your code
	}
	
	public boolean changeCellNumber(String name, String newcellnum)
	{
		return false; // replace this line with your code
	}
	
	public void sort()
	{
		// complete this method
	}
	
}



Is This A Good Question/Topic? 0
  • +

Replies To: Missing Return Statement

#2 malerv  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 100
  • Joined: 01-July 09

Re: Missing Return Statement

Posted 19 July 2009 - 02:49 PM

public int getSize()
mean that you need to return an int
like
public int getSize()
	{
		actualSize = CellPhoneBook.length - 1;
		System.out.println("The size of the phone book is:" + actualSize);	
		return actualSize;	  
}


or declaring it void
public void getSize()
	{
		actualSize = CellPhoneBook.length - 1;
		System.out.println("The size of the phone book is:" + actualSize);	
}


Was This Post Helpful? 0
  • +
  • -

#3 luron31  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 19-July 09

Re: Missing Return Statement

Posted 19 July 2009 - 02:53 PM

ohhhhhhhhhhhhhhhhhhhhh okay. :) thank you
Was This Post Helpful? 0
  • +
  • -

#4 malerv  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 100
  • Joined: 01-July 09

Re: Missing Return Statement

Posted 19 July 2009 - 02:58 PM

Usually whan a function is name getXXXX it mean that calling it give us the value.
(does this sentence make sens in english?)
Was This Post Helpful? 0
  • +
  • -

#5 luron31  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 19-July 09

Re: Missing Return Statement

Posted 19 July 2009 - 03:05 PM

View Postmalerv, on 19 Jul, 2009 - 01:58 PM, said:

Usually whan a function is name getXXXX it mean that calling it give us the value.
(does this sentence make sens in english?)



haha at first no. but after reading it again yes.
Was This Post Helpful? 0
  • +
  • -

#6 luron31  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 19-July 09

Re: Missing Return Statement

Posted 19 July 2009 - 03:13 PM

while i still have your attention: how can i initialize a multi-dimensional array that is initially empty but can hold up to a specified amount of entries?
Was This Post Helpful? 0
  • +
  • -

#7 malerv  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 100
  • Joined: 01-July 09

Re: Missing Return Statement

Posted 19 July 2009 - 03:18 PM

There is here a really good tutorial wich will answer all your questio about array.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1