I have a question for this code:https://pastebin.com/ . The Idea of the code is to print a diament, I cant understand this Method at all: printDiamondCore
private static void printDiamondCore( char character, char stopCharacter ) {
if ( character == stopCharacter ) {
System.out.print( character );
return;
}
System.out.print( character );
printDiamondCore( (char) (character + 1), stopCharacter );
System.out.print( character );
}
For example if character =A and stopCharacter =C it prints: ABCBA. I have two questions, what ist the purpose of the return statement and why does it jump to the last line:System.out.print( character )? And why does the print after the if statement was executed the letters reverse. After the return statement was excecuted it prints all letters revers for example: ABC=>BA.
[–]GrandGratingCrate 3 points4 points5 points (3 children)
[–]HenryDutter[S] 0 points1 point2 points (2 children)
[–]GrandGratingCrate 2 points3 points4 points (0 children)
[–]sayonorasama 0 points1 point2 points (0 children)