tags:

views:

121

answers:

2
Node<Integer> soln = question(n,n,null);

where question(n,n,null) returns null, now i want to output the result as "no solution";

i wrote

Node<Integer> soln = question(n,n,null);
if(soln==null) System.out.println("no solution");

An error occurs, what shall i do?

A: 

Looks like question has a void return type. That would explain your error. Likely you want it to return an Integer.

Rich
hi thanx for reply, return type of question is Node<Integer> question
What's the error? Runtime/compile time?
Rich
+1  A: 

Syntax error somewhere else?

This works just fine for me:

public class Node 
{
    public static void main(String[] args)
    {
        Node s = question(1,2,null);
        if (s == null)
            System.out.println("No solution");

    }

    public static Node question(int x, int y, String z)
    {
        if (z == null)
            return null;
        return new Node();
    }

}
Michael Clerx
hi thanx for reply, return type of question is Node<Integer> question , no syntax errors elsewhere
What's the error?
Michael Clerx