Click here to Skip to main content
11,929,675 members (55,854 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java
import java.util.Scanner;
public class sum_number
	public static void main(String[] args)
		int a,b,c, sum;
		Scanner input = new Scanner(;
		System.out.print("Enter any number:\n");
		a = input.nextInt();
		System.out.print("Enter another number:");
		b = input.nextInt();
		System.out.print("The addtion result of the entered numbers is: " +z);
	public static isum(int a, int b)
		int z;
		z= a+b;
		return z;

//Here is the result what I got. Please help me by correcting this code:

C:\Users\Sanjib\Documents\ invalid method declaration; return type required
	public static isum(int a, int b)
1 error
Tool completed with exit code 1
Posted 29-Dec-12 18:53pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Change this

public static isum(int a, int b)
to this:

public static int isum(int a, int b)
In simple words, any method in java has to specify what datatype it will be returning, in this case an integer.

Seems like you are new to programming, I advice you to get a good java book to have a good understanding. I recommend this to get started - Java The Complete Reference[^]
ridoy 30-Dec-12 1:43am
exactly what needed..+5
TorstenH. 30-Dec-12 2:44am
...and please use a IDE like Eclipse or Netbeans. Both are free and both would show you those errors.
suhan 2012 31-Dec-12 5:20am
I changed the line as what Karthik said, but found no improvement. BTW I am using "Java Programming by Joyce Farrell". Is this a good book for me as a beginner? Waiting for your reply..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100