Java && || operators precedent - java

I need help with one if condition in java code
public class Main
{
public static void main(String[] args) {
String sHeaderStatus = "1";
Boolean hasButton = false;
Boolean editableLineStatus =true;
String sFrom = "REQ";
int canChangeSupplier = 0;
if ((sHeaderStatus.equals("1") || canChangeSupplier == 1 &&
(sHeaderStatus.equals("10") || sHeaderStatus.equals("14") || sHeaderStatus.equals("85") || sHeaderStatus.equals("86") || sHeaderStatus.equals("87"))
|| hasButton && editableLineStatus && !sHeaderStatus.equals("85")) || sFrom.equals("APPROVAL")) {
String valdiaton ="true11";
System.out.println(valdiaton);
}
}
result is true11
public class Main
{
public static void main(String[] args) {
String sHeaderStatus = "1";
Boolean hasButton = false;
Boolean editableLineStatus =false; //changed this one to false
String sFrom = "REQ";
int canChangeSupplier = 0;
if ((sHeaderStatus.equals("1") || canChangeSupplier == 1 &&
(sHeaderStatus.equals("10") || sHeaderStatus.equals("14") || sHeaderStatus.equals("85") || sHeaderStatus.equals("86") || sHeaderStatus.equals("87"))
|| hasButton && editableLineStatus && !sHeaderStatus.equals("85")) || sFrom.equals("APPROVAL")) {
String valdiaton ="true11";
System.out.println(valdiaton);
}
}
result is still true11
I am not able to understood the issue.
Per my understanding...
sHeaderStatus.equals("1") || canChangeSupplier == 1 // gave true
(sHeaderStatus.equals("10") || sHeaderStatus.equals("14") || sHeaderStatus.equals("85") || sHeaderStatus.equals("86") || sHeaderStatus.equals("87"))
|| hasButton // gave false
become true && false && true && true
Similarly second code would become true && false && false &&true
Am not sure how this become true and below line printed.

&& happens before ||
Write the code like this
if (
(
sHeaderStatus.equals("1")
|| canChangeSupplier == 1 && (sHeaderStatus.equals("10") || sHeaderStatus.equals("14") || sHeaderStatus.equals("85") || sHeaderStatus.equals("86") || sHeaderStatus.equals("87"))
|| hasButton && editableLineStatus && !sHeaderStatus.equals("85")
)
|| sFrom.equals("APPROVAL")
)
You can see that you always will have (something) || false with the values given.
And changing only editableLineStatus will modify only the operator "grouping" for hasButton && editableLineStatus && !sHeaderStatus.equals("85").
However, regardless of what you change that to, you have sHeaderStatus.equals("1"), which is true, resulting in logic of
(true || (false && false) || (false && true/false && true)) || false
which, in total, is true, therefore entering the conditional

Related

Is there a way to loop this is I don't have to write it out 57 times?

I have a program that quotes up to 57 customizable products at one time. If there is a compatibility issue within one of the products the customer designs, an error pops up and a quote is not generated. I have it so if the generate button on line 57 is clicked, the program will check if lines 57, 56, 55... down to 1 are correct, then it will generate if they are. If line 56 is clicked, it checks 56 down to 1.
Is there a ways to loop is so that I only have to write it out once?
Here is my code:
if(e.getSource() == CA1.BTNgeneratequoteCA1)
{
if(CA1.generateCA1 == true)
{
try
{
FillAllKIS();
E2fill();
FillQuote();
}
catch(IOException y)
{
Logger.severe(y.getMessage());
}
RecordAllLines();
}
}
// if statments for lines 2 to 56 here
if(e.getSource() == CA57.BTNgeneratequoteCA1)
{
if(CA1.generateCA1 == true && CA2.generateCA1 == true && CA3.generateCA1 == true && CA4.generateCA1 == true && CA5.generateCA1 == true &&
CA6.generateCA1 == true && CA7.generateCA1 == true && CA8.generateCA1 == true && CA9.generateCA1 == true && CA10.generateCA1 == true &&
CA11.generateCA1 == true && CA12.generateCA1 == true && CA13.generateCA1 == true && CA14.generateCA1 == true && CA15.generateCA1 == true &&
CA16.generateCA1 == true && CA17.generateCA1 == true && CA18.generateCA1 == true && CA19.generateCA1 == true && CA20.generateCA1 == true &&
CA21.generateCA1 == true && CA22.generateCA1 == true && CA23.generateCA1 == true && CA24.generateCA1 == true && CA25.generateCA1 == true &&
CA26.generateCA1 == true && CA27.generateCA1 == true && CA28.generateCA1 == true && CA29.generateCA1 == true && CA30.generateCA1 == true &&
CA31.generateCA1 == true && CA32.generateCA1 == true && CA33.generateCA1 == true && CA34.generateCA1 == true && CA35.generateCA1 == true &&
CA36.generateCA1 == true && CA37.generateCA1 == true && CA38.generateCA1 == true && CA39.generateCA1 == true && CA40.generateCA1 == true &&
CA41.generateCA1 == true && CA42.generateCA1 == true && CA43.generateCA1 == true && CA44.generateCA1 == true && CA45.generateCA1 == true &&
CA46.generateCA1 == true && CA47.generateCA1 == true && CA48.generateCA1 == true && CA49.generateCA1 == true && CA50.generateCA1 == true &&
CA51.generateCA1 == true && CA52.generateCA1 == true && CA53.generateCA1 == true && CA54.generateCA1 == true && CA55.generateCA1 == true &&
CA56.generateCA1 == true && CA57.generateCA1 == true)
{
try
{
FillAllKIS();
E2fill();
FillQuote();
}
catch(IOException y)
{
Logger.severe(y.getMessage());
}
RecordAllLines();
}
I thought about doing it with a list filled with the instances of the classes but I'm struggling to think of how the logic would work for checking the boolean of each line, since there is another one to check with each added line item.
/* Create a list to hold CA1..CA57 */
List<MyClass> allCas = new ArrayList<>();
/* As you create CA1..CA57, whether in a loop or hardcoded, add them to your list, in order*/
...
allCas.add(CA1);
...
allCas.add(CA31);
...
allCas.add(CA57);
/* When button is clicked, find the related CA instance and check the preceding objects too. */
int selected = IntStream.range(0, allCas.size())
.filter(idx -> e.getSource() == allCas.get(idx))
.findFirst().getAsInt() + 1;
if (allCas.stream().limit(selected).allMatch(ca -> ca.generateCA1)) {
/* Fill quote and stuff. */
...
}

Substring can't find what it should find

I have a string (replacedLigning) containing y=3-2+4x-6. I want xVærdi (an ArrayList) to contain the x value. In the example y=3-2+4x-6 I want the xVærdi to store "4", since that's how many x'es there are. The initial value of xVærdi is none, and the problem is, that substring isn't able to find the "x", so the xVærdi will not contain any elements. Or so I think.
the i is initialized as 1
while(isNumber(replacedLigning.substring((replacedLigning.indexOf("x")-i),(replacedLigning.indexOf("x")-i+1))) == true){
xVærdi.add(replacedLigning.substring((replacedLigning.indexOf("x")-i),(replacedLigning.indexOf("x")-i+1)));
i++;
}
And
System.out.println(xVærdi); //It doesn't contain anything. Output: []
The isNumber method:
public static boolean isNumber(String str) {
if((str.equals("-") && fortegn == false)){
fortegn = true; //fortegn is a variable that allows the number to have it's minus with it
return true;
}
else if (str.equals("+") || str.equals("*") || str.equals("/") || str.equals("=")){
return false;
} else if((str.equals(".") && !fortegn) || (str.equals("0") && !fortegn) || (str.equals("1") && !fortegn) || (str.equals("2") && !fortegn) || (str.equals("3") && !fortegn) || (str.equals("4") && !fortegn) ||
(str.equals("5") && !fortegn) || (str.equals("6") && !fortegn) || (str.equals("7") && !fortegn) || (str.equals("8") && !fortegn) || (str.equals("9") && !fortegn)){
return true;
} else
return false;
}
EDIT:
I have made a mini-program, as you can see below. However, the error does not occur in this example, so I am at a loss why it is happening. So I'm uploading a bigger part of my program. My output is 4, which is intended, and occurs.
import java.util.*;
import java.lang.*;
public class Eksempel {
private static boolean fortegn = false;
private static int i = 1;
static ArrayList xVærdi = new ArrayList();
private static String ligning = "y=3-2+4x-6";
public static boolean erTal(String str) {
if((str.equals("-") && fortegn == false)){ //Variablen 'fortegn' sørger for at inkludere fortegnet af et tal, selvom det ikke er et tal. Dette sker kun en gang.
fortegn = true;
return true;
}
else if (str.equals("+") || str.equals("*") || str.equals("/") || str.equals("=")){
return false;
} else if((str.equals(".") && !fortegn) || (str.equals("0") && !fortegn) || (str.equals("1") && !fortegn) || (str.equals("2") && !fortegn) || (str.equals("3") && !fortegn) || (str.equals("4") && !fortegn) ||
(str.equals("5") && !fortegn) || (str.equals("6") && !fortegn) || (str.equals("7") && !fortegn) || (str.equals("8") && !fortegn) || (str.equals("9") && !fortegn)){
return true;
} else //Kommer kun så langt hvis klienten har indtastet et bogstav andet end x.
return false;
}
public static void main(String[] args) {
while(erTal(ligning.substring((ligning.indexOf("x")-i),(ligning.indexOf("x")-i+1))) == true){
xVærdi.add(ligning.substring((ligning.indexOf("x")-i),(ligning.indexOf("x")-i+1)));
i++;
}
Collections.reverse(xVærdi);
double xResult = Double.parseDouble(String.join("", xVærdi));
System.out.println(xResult); //returns 4.0 which it should
}}
The longer code that doesn't work:
import java.util.*;
import java.lang.*;
public class Server{
private static String ligning = y=3x^3-2x^2+4x-6;
private static String replacedLigning;
private static int i = 1;
static ArrayList xVærdi = new ArrayList();
static ArrayList x2Værdi = new ArrayList();
static ArrayList x3Værdi = new ArrayList();
while(erTal(ligning.substring((ligning.indexOf("x^3")-i),
(ligning.indexOf("x^3")-i+1))) == true){
x3Værdi.add(ligning.substring((ligning.indexOf("x^3")-i),
(ligning.indexOf("x^3")-i+1)));
i++;
}
replacedLigning = ligning.replace("x^3","");
while(erTal(replacedLigning.substring((replacedLigning.indexOf("x^2")-i),(replacedLigning.indexOf("x^2")-i+1))) == true){
x2Værdi.add(replacedLigning.substring((replacedLigning.indexOf("x^2")-i),(replacedLigning.indexOf("x^2")-i+1)));
i++;
}
System.out.println(replacedLigning); //gives: y=3-2x^2+4x-6
replacedLigning = replacedLigning.replace("x^2","");
System.out.println(replacedLigning); //gives y=3-2+4x-6
i=1;
while(erTal(replacedLigning.substring((replacedLigning.indexOf("x")-i),(replacedLigning.indexOf("x")-i+1))) == true){
xVærdi.add(replacedLigning.substring((replacedLigning.indexOf("x")-i),(replacedLigning.indexOf("x")-i+1)));
i++;
}
Collections.reverse(xVærdi);
Collections.reverse(x2Værdi);
Collections.reverse(x3Værdi);
System.out.println(xVærdi); **//Contains nothing: [] should contain [4]**
System.out.println(x2Værdi); **//Contains nothing: [] should contain [-2]**
System.out.println(x3Værdi); **//Contains [4, ., 6, -] should contain [3]**
double xResult = Double.parseDouble(String.join("", xVærdi)); //gets an error, because the arraylist is empty.
double x2Result = Double.parseDouble(String.join("", x2Værdi));
double x3Result = Double.parseDouble(String.join("", x3Værdi));

Java Multi-Dimensional Arrays in a Method

I'm knew with multi-dimensional arrays and I kind of know the basics but I'm stuck on combining them into a boolean method. In this case, I'm trying to find out how I can make this method simplified which will function as:
Comparing one array with a location (row:column) to another array (with the same location).
If all locations from both arrays match, it should return true.
The method below works with what I have for my code but I want to know the proper way on how to not "hard code" the numbers single handedly. Would I need to use a nested for loop for comparing both arrays?
Thanks for the assistance~
public static boolean gameIsWon(int[][] workingPuzzle, int[][] solvedPuzzle)
{
if (workingPuzzle[0][0] == solvedPuzzle[0][0] &&
workingPuzzle[0][1] == solvedPuzzle[0][1] &&
workingPuzzle[0][2] == solvedPuzzle[0][2] &&
workingPuzzle[0][3] == solvedPuzzle[0][3] &&
workingPuzzle[0][4] == solvedPuzzle[0][4] &&
workingPuzzle[0][5] == solvedPuzzle[0][5] &&
workingPuzzle[0][6] == solvedPuzzle[0][6] &&
workingPuzzle[0][7] == solvedPuzzle[0][7] &&
workingPuzzle[0][8] == solvedPuzzle[0][8] &&
workingPuzzle[1][0] == solvedPuzzle[1][0] &&
workingPuzzle[1][1] == solvedPuzzle[1][1] &&
workingPuzzle[1][2] == solvedPuzzle[1][2] &&
workingPuzzle[1][3] == solvedPuzzle[1][3] &&
workingPuzzle[1][4] == solvedPuzzle[1][4] &&
workingPuzzle[1][5] == solvedPuzzle[1][5] &&
workingPuzzle[1][6] == solvedPuzzle[1][6] &&
workingPuzzle[1][7] == solvedPuzzle[1][7] &&
workingPuzzle[1][8] == solvedPuzzle[1][8] &&
workingPuzzle[2][0] == solvedPuzzle[2][0] &&
workingPuzzle[2][1] == solvedPuzzle[2][1] &&
workingPuzzle[2][2] == solvedPuzzle[2][2] &&
workingPuzzle[2][3] == solvedPuzzle[2][3] &&
workingPuzzle[2][4] == solvedPuzzle[2][4] &&
workingPuzzle[2][5] == solvedPuzzle[2][5] &&
workingPuzzle[2][6] == solvedPuzzle[2][6] &&
workingPuzzle[2][7] == solvedPuzzle[2][7] &&
workingPuzzle[2][8] == solvedPuzzle[2][8] &&
workingPuzzle[3][0] == solvedPuzzle[3][0] &&
workingPuzzle[3][1] == solvedPuzzle[3][1] &&
workingPuzzle[3][2] == solvedPuzzle[3][2] &&
workingPuzzle[3][3] == solvedPuzzle[3][3] &&
workingPuzzle[3][4] == solvedPuzzle[3][4] &&
workingPuzzle[3][5] == solvedPuzzle[3][5] &&
workingPuzzle[3][6] == solvedPuzzle[3][6] &&
workingPuzzle[3][7] == solvedPuzzle[3][7] &&
workingPuzzle[3][8] == solvedPuzzle[3][8] &&
workingPuzzle[4][0] == solvedPuzzle[4][0] &&
workingPuzzle[4][1] == solvedPuzzle[4][1] &&
workingPuzzle[4][2] == solvedPuzzle[4][2] &&
workingPuzzle[4][3] == solvedPuzzle[4][3] &&
workingPuzzle[4][4] == solvedPuzzle[4][4] &&
workingPuzzle[4][5] == solvedPuzzle[4][5] &&
workingPuzzle[4][6] == solvedPuzzle[4][6] &&
workingPuzzle[4][7] == solvedPuzzle[4][7] &&
workingPuzzle[4][8] == solvedPuzzle[4][8] &&
workingPuzzle[5][0] == solvedPuzzle[5][0] &&
workingPuzzle[5][1] == solvedPuzzle[5][1] &&
workingPuzzle[5][2] == solvedPuzzle[5][2] &&
workingPuzzle[5][3] == solvedPuzzle[5][3] &&
workingPuzzle[5][4] == solvedPuzzle[5][4] &&
workingPuzzle[5][5] == solvedPuzzle[5][5] &&
workingPuzzle[5][6] == solvedPuzzle[5][6] &&
workingPuzzle[5][7] == solvedPuzzle[5][7] &&
workingPuzzle[5][8] == solvedPuzzle[5][8] &&
workingPuzzle[6][0] == solvedPuzzle[6][0] &&
workingPuzzle[6][1] == solvedPuzzle[6][1] &&
workingPuzzle[6][2] == solvedPuzzle[6][2] &&
workingPuzzle[6][3] == solvedPuzzle[6][3] &&
workingPuzzle[6][4] == solvedPuzzle[6][4] &&
workingPuzzle[6][5] == solvedPuzzle[6][5] &&
workingPuzzle[6][6] == solvedPuzzle[6][6] &&
workingPuzzle[6][7] == solvedPuzzle[6][7] &&
workingPuzzle[6][8] == solvedPuzzle[6][8] &&
workingPuzzle[7][0] == solvedPuzzle[7][0] &&
workingPuzzle[7][1] == solvedPuzzle[7][1] &&
workingPuzzle[7][2] == solvedPuzzle[7][2] &&
workingPuzzle[7][3] == solvedPuzzle[7][3] &&
workingPuzzle[7][4] == solvedPuzzle[7][4] &&
workingPuzzle[7][5] == solvedPuzzle[7][5] &&
workingPuzzle[7][6] == solvedPuzzle[7][6] &&
workingPuzzle[7][7] == solvedPuzzle[7][7] &&
workingPuzzle[7][8] == solvedPuzzle[7][8] &&
workingPuzzle[8][0] == solvedPuzzle[8][0] &&
workingPuzzle[8][1] == solvedPuzzle[8][1] &&
workingPuzzle[8][2] == solvedPuzzle[8][2] &&
workingPuzzle[8][3] == solvedPuzzle[8][3] &&
workingPuzzle[8][4] == solvedPuzzle[8][4] &&
workingPuzzle[8][5] == solvedPuzzle[8][5] &&
workingPuzzle[8][6] == solvedPuzzle[8][6] &&
workingPuzzle[8][7] == solvedPuzzle[8][7] &&
workingPuzzle[8][8] == solvedPuzzle[8][8]
)
return true;
else
return false;
}
You need to learn about loops.
And about storing a two-dimensional matrix in a one-dimensional array using index mapping (which is easier to handle than a two-dimensional array).
But in this particular case:
return java.util.Arrays.deepEquals(workingPuzzle, solvedPuzzle);
Use nested for loops based on the array lengths.
public static boolean gameIsWon(int[][] workingPuzzle, int[][] solvedPuzzle) {
if(workingPuzzle.length != solvedPuzzle.length) {
return false;
}
for(int i = 0; i < workingPuzzle.length; i++) {
if(workingPuzzle[i].length != solvedPuzzle[i].length) {
return false;
}
for(int j = 0; j < workingPuzzle[i].length; j++) {
if(workingPuzzle[i][j] != solvedPuzzle[i][j]) {
return false;
}
}
}
return true;
}

Java: Wildcard Pattern Matching

I have been trying to solve the Wildcard pattern matching and I have found a working solution in the below link:
http://www.geeksforgeeks.org/wildcard-character-matching/
I have written an Equivalent java code for the C code given in the above link, which is:
public class wildcard
{
public static void main(String[] args)
{
test("g*ks", "geeks");
//test("g*k", "gee");
//test("c*d*", "cad");
}
static boolean matches(String format, String data)
{
if (format.length() == 0 && data.length() == 0)
{
return true;
}
if ((format.charAt(0) == '*' && format.charAt(1) != 0 && data.length() == 0) && (format.length() != 0 && data.length() != 0))
{
return false;
}
if ((format.charAt(0) == '?' || format.charAt(0) == data.charAt(0)) && (format.length() != 0 && data.length() != 0))
{
return matches(format.substring(1), data.substring(1));
}
if ((format.charAt(0) == '*')&& (format.length() != 0 && data.length() != 0))
{
return matches(format.substring(1), data) || matches(format, data.substring(1));
}
return false;
}
static void test(String first, String second)
{
System.out.println(matches(first, second));
}
}
On Execution, a String out of bounds Exception is thrown, which is:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.charAt(String.java:658)
at wildcard.matches(wildcard.java:29)
at wildcard.matches(wildcard.java:36)
at wildcard.matches(wildcard.java:42)
at wildcard.matches(wildcard.java:42)
at wildcard.matches(wildcard.java:36)
at wildcard.test(wildcard.java:52)
at wildcard.main(wildcard.java:16)
I can see that this exception occurs at the CharAt() method, is there any other way to make this work??
:)
First I noticed that the code && (format.length() != 0 && data.length() != 0) is not on the original code from the page you provide and are causing conflicts with your algorithm so I remove it and it looks like this:
static boolean matches(String format, String data) {
if (format.length() == 0 && data.length() == 0) {
return true;
}
if (format.charAt(0) == '*' && format.charAt(1) != 0 && data.length() == 0) {
return false;
}
if (format.charAt(0) == '?' || format.charAt(0) == data.charAt(0)) {
return matches(format.substring(1), data.substring(1));
}
if (format.charAt(0) == '*') {
return matches(format.substring(1), data) || matches(format, data.substring(1));
}
return false;
}
The problems I talked about are in the second condition you have data.length() == 0 and in the code I remove was data.length() != 0, so that condition was always false because the length cannot be 0 and not 0 at the same time.
I discovered two problems. The first one was that some cases like matches("ge?ks*", "geeksforgeeks") end up with having a single wildcard at the format and crashed on if (format.charAt(0) == '*' && format.charAt(1) != 0 && data.length() == 0) because of format.charAt(1). To solve this I add the next code to the algorithm:
if (format.length() == 1 && format.charAt(0) == '*')
return true;
The other problem was when the format was empty but still have data and solve it with:
if (format.length() == 0 && data.length() > 0)
return false;
The final algorithm looks like this:
static boolean matches(String format, String data) {
if (format.length() == 0 && data.length() == 0)
return true;
if (format.length() == 1 && format.charAt(0) == '*')
return true;
if (format.length() == 0 && data.length() > 0)
return false;
if (format.charAt(0) == '*' && format.charAt(1) != 0 && data.length() == 0)
return false;
if (format.charAt(0) == '?' || format.charAt(0) == data.charAt(0))
return matches(format.substring(1), data.substring(1));
if (format.charAt(0) == '*')
return matches(format.substring(1), data) || matches(format, data.substring(1));
return false;
}

Running my java code works in debugger but not in run

Running my java code works in debugger but not in run. In the eclipse debugger it shows my jframes.
However when I run it, my frame doesn't appear whatsoever.
I believe I messed up my EventListener and all that.
private class ButtonHandler implements ActionListener{
JButton button;
public void actionPerformed(ActionEvent event) {
find(event.getSource());
button = buttonHolder[indexK[kCount-1]][indexJ[jCount-1]];
if((button.getIcon() == red && choice1 == 1) || (button.getIcon() == green && choice1 == 0)){
JOptionPane.showMessageDialog(null, "You chose the wrong color!");
return;
}
if(turn ==1){
if(clicks != 1){
if(button.getIcon() == red){
clicks++;
temp = button;
}else if (button.getIcon() == green){
clicks++;
temp = button;
}else{
kCount=0;
jCount=0;
}
}else{
if((button.getIcon() == green) || (button.getIcon() == red)){
//do nothing
}else if(temp.getIcon() == green && (grid[indexK[1]][indexJ[1]] == 2 || grid[indexK[1]][indexJ[1]] == 3 || grid[indexK[1]][indexJ[1]] == 4) && button.getIcon() != green && ((indexK[0]+1 ==indexK[1] && indexJ[0] == indexJ[1]) || (indexK[0] ==indexK[1] && indexJ[0]+1 == indexJ[1]) || (indexK[0] ==indexK[1] && indexJ[0]-1 == indexJ[1])) ){
temp.setIcon(null);
button.setIcon(green);
grid[indexK[1]][indexJ[1]] = 2;
if(indexK[0] == 0 || indexK[0]== 9){
grid[indexK[0]][indexJ[0]] = 4;
}else{
grid[indexK[0]][indexJ[0]] =3;
}
found = 2;
}else if(temp.getIcon() == red && (grid[indexK[1]][indexJ[1]] == 1 || grid[indexK[1]][indexJ[1]] == 3 || grid[indexK[1]][indexJ[1]] == 5) && button.getIcon() != red && ((indexK[0]+1 ==indexK[1] && indexJ[0] == indexJ[1]) || (indexK[0] ==indexK[1] && indexJ[0]+1 == indexJ[1]) || (indexK[0]-1 ==indexK[1] && indexJ[0] == indexJ[1]))){
temp.setIcon(null);
button.setIcon(red);
grid[indexK[1]][indexJ[1]] = 1;
if(indexJ[0] == 0 || indexJ[0]== 9){
grid[indexK[0]][indexJ[0]] = 5;
}else{
grid[indexK[0]][indexJ[0]] =3;
}
found = 2;
}
clicks=0;
kCount=0;
jCount=0;
}
}
}
}
}
if you don't see any problems, can you think of a reason why it might be messing up?
First, double check that you're running it in the same mode. A program made for Applet mode is not the same as Application.
If that doesn't work:
If running as an Applet:
Check that you have an init function.
If running as an Application:
Check that you define a main class in your run configuration. If you did, make sure you are running a main() method within it.

Categories