I'm trying to return the value of ?,?,? when executing the main function. However, I only get ?, as an answer. I don't want to use System.out.println (although it does the job) because I want to return the values to another function. The first return works as I want it to but in the second part, I am not sure how to concatenate the 2 returns and the for loop because useless after I've change the println with return
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
r r = new r();
System.out.println(r.func(3));
}
public static String func(int size)
{
if(size == 1)
return "?";
else
{
for (int i = 1; i < size; i++)
{
return "?,";
}
return "?";
}
}
returndoes? Why do you think that your output would be?,?,?. You mentionedconcatenationin the title but I don't see any anywhere in your code where strings are beingconcatenated?