+ 1
Compile time error
Find error and decode it https://code.sololearn.com/cNB0kf6JYuFt/?ref=app
18 Answers
+ 2
Thanx for clear my doubts Sheetal Malavade 😊
+ 2
Avinash Giri Sure 👍
+ 1
Avinash Giri , your variables x and y are not initialized. You can give them a value or use Scanner to ask user to input something.
+ 1
Avinash Giri , what is the purpose of your code?
+ 1
Yeah Sheetal Malavade
+ 1
class name should start with capital letter
and also variable x is undeclared
+ 1
make the class name as Debugging instead of debugging because java allows class names which start with a capital letter
0
declare the x value
0
But condition is not apply if I give x=3 they give me y =3 but don't check if conditionTheWh¡teCat 🇧🇬 Baci
0
What happens when x= 3 they fulfil the condition. (x>10)TheWh¡teCat 🇧🇬
0
It's not clear what is the idea of your code, Avinash Giri.
0
Put the x value in y but use if TheWh¡teCat 🇧🇬 plzz clear my doubt
0
It's not clear, only you know what do you want to do with your code, but you don't explain it, Avinash Giri.
0
Plzzz explain it I see this question in my book so I try to solve thisTheWh¡teCat 🇧🇬
0
import java.util.*;
// Compiler version JDK 11.0.2
import java.util.Scanner;
class debugging
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int x= sc.nextInt();
int y;
if (x<10)
{
y = x;
}
System.out.println(" Value of Y = "+x);
}
}
Now code is right plzz explain output
TheWh¡teCat 🇧🇬
0
Avinash Giri
the logic you have written in this program will take input X from user and checks whether it's less than 10 or not..
there is one correction in your last printf statement.. that is if you want y data to be displayed then change your code to
System.out.println("value of Y = " + y ) ..
but you have written X there ..
program will works like this ..
1. if it's less than 10 , then it will enter into if block and assigns X value to y . (y=X)
and prints the same output.
2.if X is greater than 10 suppose X= 15 , then it is false and skips the if block. and program control jumps to print statement..
he there is a small mistake would occur .. when the X value is greater than 10 , it wil never enter the if block and there wont be any value assigned to y.. and program control jumps to print statement.. since you have not initiatialised y variable in the beginning , hence it will throw error .. so 1st assign value to y so that it can print the default y value when X > 10..
0
Variable x is not declared
0
Hello Giri
I want you to help me