Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I can't seem to get the last "i" in this code to fully function, it wont respond to the initial "i", just tells me that it "cannot find symbol". What am I doing wrong?
public void fillCB (JComboBox cb){
String sqlQueryCB = "select namn from ANSTALLD order by namn";
try {
ArrayList<String> listaAnstalld = idb.fetchColumn(sqlQueryCB);
for(int i = 0; i < listaAnstalld.size(); i++); {
cb.addItem(listaAnstalld.get(i));
}
}
catch(Exception e)
{
}
you have a semicolon at the end of your for loop, before the opening brace.
for(int i = 0; i < listaAnstalld.size(); i++); {
That semicolon closes the for loop. should remove it.
because of this, the contents of your block will not be in the scope of the for loop(and therefore not in the same scope that i is in).
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
This is just a simple query if anyone knows why I am facing this error I would appreciate the help.
The problem is simple java if else if else loop problem .
so I tried to make syntax as correct as possible.
The code here below is the one I am executing.
public class ifelseloop {
public static void main(String[] args){
// int a = 20;
// int b = 20;
String city = "Delhi";
if (city == "madras") {
System.out.println("the city is not delhi its madras");
}else if(city == "chennai") {
System.out.println("the city is not delhi its chennai");
}else if(city == "bartar") {
System.out.println("the city is bartar");
}else {
System.out.println(city);
}
}
}
and the error that I am getting is this.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at ifelseloop.main(ifelseloop.java:2)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
What is the wrong of this code? need help.
public class TailRrecursion {
public static void tail(int i) {
if (i > 0) {
System.out.print(i + "");
tail(i - 1);
}
}
}
For a start, you are missing curly { braces
see
public class Tail-recursion{
public static void tail(int i) {
if(i>0){
System.out.print (i +"");
tail(i-1);
}
}
} // and here
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
The following code compiles, but when I ran it, it didn't enter the while-loop. Why ?
while (Str1.equals(Str2)); {
count = 1;
while (count <= maxCount); {
System.out.print(something1);
count = count + 1; } }
Remove the semi colon, semicolon is added only for do-while.Here is your code:
while (Str1.equals(Str2))
{
count = 1;
while (count <= maxCount)
{
System.out.print(something1);
count = count + 1;
}
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to insert data into MySQL and I'm getting an error:
cannot find symbol c
import java.sql.*;
class Insert{
public static void main(String args[]){
try{
Class.forName("com.jdbc.mysql.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3036/db","ravi","ravi");
//showing error in the below statement at c
Statement stmt = c.CreateStatement();
int result=stmt.executeUpdate("Insert into emp values(3,'david',33) ");
System.out.println("success");
c.close();
} catch(Exception e) {
System.out.println(e);
}
}
}
It's c.createStatement() and not c.CreateStatement().
You need to make that c to lowercase in the method name createStatement()
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
public class Try1 {
public static void main(String[] args) {
char ch;
for(ch='a' ;ch<='z'; ch++);
{
System.out.println(ch);
}
}
}
could not get output
try
public static void main(String[] args) {
char ch;
for(ch='a' ;ch<='z'; ch++)
{
System.out.println(ch);
}
}
You've used ; after for loop.
for this "for(ch='a' ;ch<='z'; ch++);" statement, are you sure about last semicolumn, it breaks your for loop right there only.