W
W
WannaCreative2016-09-05 21:38:55
Java
WannaCreative, 2016-09-05 21:38:55

Why is the return result not displayed?

Result not showing in console

public class Solution
{

    public static void main(String[] args)
    {
        String localString = "I live in Russia";
        data(localString);
    }

    public static int data(String s)
    {
        return s.length();
    }

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vorh, 2016-09-05
@WannaCreative

You use the return statement to return the result of the method execution, in your case it is s.lenght , now to print to the console use the
System.out.println() method .

public class Solution
{

    public static void main(String[] args)
    {
        String localString = "I live in Russia";
        System.out.println(data(localString));
    }

    public static int data(String s)
    {
        return s.length();
    }

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question