1- < p > The < code > java.io .IO</ code > class provides simple methods for interactive console I/O. For standard console input, < code > IO.readln()</ code > should
2- be preferred over the traditional, more verbose < code > BufferedReader</ code > .</ p >
1+ < p > The < code > java.lang .IO</ code > class provides simple methods for interactive console I/O. For standard console input, < code > IO.readln()</ code >
2+ should be preferred over the traditional, more verbose < code > BufferedReader</ code > .</ p >
33< h2 > Why is this an issue?</ h2 >
44< p > Traditionally, reading a line from the console required significant boilerplate code, involving < code > InputStreamReader</ code > ,
55< code > BufferedReader</ code > , and explicit < code > IOException</ code > handling. This pattern is not only verbose but also error-prone and harder to
@@ -13,8 +13,8 @@ <h2>Why is this an issue?</h2>
1313</ ul >
1414< h2 > How to fix it</ h2 >
1515< p > Replace manual stream wrapping of < code > System.in</ code > with the static < code > IO.readln()</ code > method. If you are using a version of Java where
16- < code > IO</ code > is automatically imported (such as in JShell or modern entry points), you can call < code > readln()</ code > directly; otherwise, use
17- < code > import static java.io .IO.readln;</ code > .</ p >
16+ < code > IO</ code > is automatically imported (such as in JShell or modern entry points), you can call < code > IO. readln()</ code > directly; otherwise, use
17+ < code > import static java.lang .IO.readln;</ code > .</ p >
1818< h3 > Code examples</ h3 >
1919< h4 > Noncompliant code example</ h4 >
2020< pre data-diff-id ="1 " data-diff-type ="noncompliant ">
@@ -35,7 +35,7 @@ <h4>Noncompliant code example</h4>
3535</ pre >
3636< h4 > Compliant solution</ h4 >
3737< pre data-diff-id ="1 " data-diff-type ="compliant ">
38- import static java.io .IO.readln;
38+ import static java.lang .IO.readln;
3939
4040void main() {
4141 // Compliant: concise and readable console input
0 commit comments