0

Below is the code written in java

for (int a = 1,int b = 4; a < b; a++, b--)
                System.out.println("a = " + a + " b=" + b);

It shows syntax error in int . Please tell me the reason for syntax inside for loop. when we declare int a,b , it does not show error.

2
  • 7
    remove int before b Commented Nov 18, 2016 at 12:13
  • 2
    @Anand, this is a syntactical issue, which is available on tons of sites and you should check it out to fix such issues before posting question. Commented Nov 18, 2016 at 12:16

1 Answer 1

3

try this,

remove "int" before b

import java.util.*;
    public class fib{
        public static void main(String[] args){
            for (int a = 1, b = 4; a < b; a++, b--) // reomve int before b
                    System.out.println("a = " + a + " b=" + b);
        }
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.