## Sự khác nhau giữa BufferedReader và Scanner???

Đây là bài tập kiểm tra tính đối xứng. Ở đây mình viết ra 2 trường hợp.
Ở trường hợp 1:khi cho số phần tử cần nhập xong thì bắt đầu nhập từng phần tử. Ở đây nó luôn bỏ qua phần tử đầu tiên.
Còn trường hợp thứ 2 lại ko.
Các bạn giải thích cho mình vs??
1.Sử dụng Scanner
Code:
```import java.util.*;
import java.io.*;
public class Demo1{
public static void main(String[] args) throws Exception{
Scanner scan=new Scanner(System.in);
Palindrom palindrom= new Palindrom();
String[] str=new String[20];
System.out.println("So phan tu can nhap");
int n;
n=scan.nextInt();
for(int i=0;i<n;i++){
System.out.println("Phan tu " +(i+1));
str[i]=scan.nextLine();
}
for(int i=0;i<n;i++){
if(palindrom.test(str[i])==true) System.out.print(str[i]);
}
}
}
class Palindrom{
public boolean test(String a){
boolean k=true;
for(int i=0;i<(int)a.length()/2;i++){
if(!a.substring(i,i+1).equals(a.substring(a.length()-i-1,a.length()-i))){
k=false;
break;
}
k=true;
}
return k;
}
}```
Code:
```import java.util.*;
import java.io.*;
public class BT201{
public static void main(String[] args) throws Exception{
Scanner scan=new Scanner(System.in);
Palindrom palindrom= new Palindrom();
String[] str=new String[20];
System.out.println("So phan tu can nhap");
int n;
n=scan.nextInt();
for(int i=0;i<n;i++){
System.out.println("Phan tu " +(i+1));
}
for(int i=0;i<n;i++){
if(palindrom.test(str[i])==true) System.out.print(str[i]);
}
}
}
class Palindrom{
public boolean test(String a){
boolean k=true;
for(int i=0;i<(int)a.length()/2;i++){
if(!a.substring(i,i+1).equals(a.substring(a.length()-i-1,a.length()-i))){
k=false;
break;
}
k=true;
}
return k;
}
}```