To produce a nested comment thread, you first need the comment system to be capable of referring a comment to the ID of a parent comment. This is pretty standard so you likely have that already. Now ...
Learn how to use statements like if, if-else, switch, for, and while to declare variables and specify expressions, make decisions, iterate over statements, and more. Java applications evaluate ...