Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question