Skip to content

Instantly share code, notes, and snippets.

@Fogest
Created December 6, 2013 04:28
Show Gist options
  • Save Fogest/7818574 to your computer and use it in GitHub Desktop.
Save Fogest/7818574 to your computer and use it in GitHub Desktop.
package main;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Boolean checker = true;
String regex = "^(?:([0-9])(?!.*\1))*$";
Pattern pattern = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
System.out.println("Enter the Year:");
String number = input.next();
Matcher matcher;
while(!checker) {
matcher = pattern.matcher(number);
if(matcher.find())
checker = true;
else
number++;
}
System.out.println(number);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment