Java Practice It || 6.13 stripComments || file processing, nested while loop, .subString(), Strings

preview_player
Показать описание
Problem:

How to use .substring() video:

How to use .indexOf() video:

Question:
Write a method called stripComments that accepts a Scanner representing an input file containing a Java program as its parameter, reads that file, and then prints the file's text with all comments removed. A comment is any text on a line from // to the end of the line, and any text between /* and */ characters. For example, consider the following text:

/* My program
by Suzy Student */
public class Program {
public static void main(String[] args) {
}

public static /* Hello there */ void foo() {
} /* */
}
If the file contained this text, your program should output the following text:

public class Program {
public static void main(String[] args) {
}

public static void foo() {
}
}
Рекомендации по теме
Комментарии
Автор

Hi do you have a main method for this question?

mingming
join shbcf.ru