Trouble with Binary Recursion

So I'm having trouble with this program, I have to have the user input a sequence of 0's and 1's. And then I have to use recursion to calculate the non-negative int and print it, but I keep getting error messages and I can't figure out what the problem is. The error message currently is the public void printBinary (int n) saying illegal start of expression. But I'm literally looking at past coding assignments and I have it written the exact way on other programs and it compiles.

import java.util.Scanner;
public class Binary
    public static void main (String[]args){
    int n;
    int counter = 1;
    Scanner scan = new Scanner(;

    System.out.println ("Please a sequence of 1's and 0's");
    n= scan.nextInt();

    for (int index = 0; index < string1.length();
    index++) {
    char aChar = string1.charAt(index);

    public void printBinary (int n) {
    if (n < 0 || n > 2) {         //base case
        System.out.println ("Error. Please enter 1 or 0");
        n = scan.nextInt();}
    else if (n < 2) {    //base case
    else {
        printBinary(n/2);   //recursive step
        int answer = n%2;