Max XOR

Given two integers: L and R, find the maximal values of A xor B given, L ≤ A ≤ B ≤ R.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
/*
* Complete the function below.
*/

static int maxXor(int l, int r) {
int max=0,tmp;
for(int i=l;i<=(r+1);i++)
{
if(i==r)
{
l+=1;
i=l;
}
if(l>=r)
break;
tmp=l^i;
if(tmp>max)
max=tmp;
}
return max;
}

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int res;
int _l;
_l = Integer.parseInt(in.nextLine());

int _r;
_r = Integer.parseInt(in.nextLine());

res = maxXor(_l, _r);
System.out.println(res);

}
}