So I have a code that appears like it would have perfect formatting in Notepad++, but when I login to my Unix timeshare, open vim, and paste the code into the newly created file, it later has problems compiling. I keep getting "class, interface, or enum expected" errors, however my code appears to have the right amount of brackets and such. I've even tried using Filezilla to transfer my java file in to my unix folder, but I get the same errors. Does anybody else experience problems while transferring code from Notepad++ to Unix? If so, is there a way I can fix this? I've provided my code below; it is meant to find the roots of an entered polynomial using the bisection method:
import java.util.*;
class Roots {
public static int degree;
public static double[] coArrayC;
public static double[] coArrayD;
public static int coeffiNumb;
public static void main( String[] args ){
double resolution = 0.01;
double threshold = 0.001;
double tolerance = 0.0000001;
double rightEndPt;
double leftEndPt;
int polyRootPointer = 0;
int diffRootPointer = 0;
boolean rootAns = false;
Scanner sc = new Scanner(System.in);
System.out.println();
System.out.print("Enter the degree: ");
degree = sc.nextInt();
coeffiNumb = degree + 1;
System.out.print("Enter " + coeffiNumb + " coefficients: ");
double[] coefficients = new double[coeffiNumb];
coArrayC = new double[coeffiNumb];
double[] rootArray = new double[degree];
coArrayD = new double[coeffiNumb];
double[] rootArrayDeriv = new double[degree];
for(int i = 0; i < coeffiNumb; i++) {
coefficients[i] = sc.nextDouble();
}
System.out.print("Enter the lower and upper endpoints, in that order: ");
leftEndPt = sc.nextDouble();
rightEndPt = sc.nextDouble();
diff(coefficients);
for (double i = leftEndPt; i < rightEndPt-resolution; i = i + resolution){
if (isPositive(coArrayD, i) != isPositive(coArrayD, i+resolution) || isPositive(coArrayD, i) == 0) {
rootArrayDeriv[diffRootPointer] = findRoot(coArrayD, i, i+resolution, tolerance);
diffRootPointer++;
}
}
for (int i = 0; i < rootArrayDeriv.length; i++) {
double tempVal;
tempVal = poly(coefficients, rootArrayDeriv[i]);
tempVal = Math.abs(tempVal);
if (tempVal < threshold) {
rootArray[polyRootPointer] = rootArrayDeriv[i];
polyRootPointer++;
rootAns = true;
}
}
for (double i = leftEndPt; i < rightEndPt-resolution; i = i + resolution){
if (isPositive(coefficients, i) != isPositive(coefficients, i+resolution) || isPositive(coefficients, i) == 0) {
rootArray[polyRootPointer] = findRoot(coefficients, i, i+resolution, tolerance);
polyRootPointer++;
rootAns = true;
}
}
Arrays.sort(rootArray);
if (rootAns == false) {
System.out.println("Sorry - no roots were found at that particular interval.");
}
}
} else {
for (int i = 0; i < rootArray.length; i++) {
if (rootArray[i] != 0.0) {
System.out.printf("Root found at %.5f%n", Arrays.sort(rootArray));
}
}
static double poly(double[] C, double x){
double polySum = 0;
coArrayC[0] = C[0];
for (int i = 1; i < coArrayC.length; i++){
coArrayC[i] = C[i]*(Math.pow(x, i));
}
for (int i = 0; i < coArrayC.length; i++){
polySum = polySum + coArrayC[i];
}
return(polySum);
}
static double[] diff(double[] C){
for (int i = 0; i < degree; i++){
coArrayD[i] = (i+1)*C[i+1];
}
return(coArrayD);
}
static double findRoot(double[] C, double a, double b, double tolerance){
double root = 0.0 , residual;
while ( Math.abs(b - a) > tolerance ) {
root = (a + b) / 2.0;
residual = poly(C, root);
if (poly(C, a) > 0 && poly(C, b) < 0) {
if (residual > 0)
a = root;
else
b = root;
} else if (poly(C, a) < 0 && poly(C, b) > 0) {
if (residual > 0)
b = root;
else
a = root;
}
}
return(root);
}
static int isPositive(double[] C, double a){
double endpointTempA;
endpointTempA = poly(C, a);
if (endpointTempA < 0) {
return(1);
} else if (endpointTempA > 0) {
return(2);
} else {
return(0);
}
}
}
Related
public class Amstrong {
public static void main(String[] args) {
for (int i = 100; i < 1000; i++) {
String a = String.valueOf(i);
int b = a.charAt(0);
int c = a.charAt(1);
int d = a.charAt(2);
int e = b * b * b + c * c * c + d * d * d;
if (e == i) {
System.out.println(i);
}
}
}
}
//Help me out please, no error occurred but the result returned in the blank
You are not converting the characters to digits correctly.
One of the possible ways to fix it:
int b = a.charAt(0)-'0';
int c = a.charAt(1)-'0';
int d = a.charAt(2)-'0';
Another way:
int b = Character.digit (a.charAt(0),10);
int c = Character.digit (a.charAt(1),10);
int d = Character.digit (a.charAt(2),10);
Either way will give your the output:
153
370
371
407
Another way you can do it is:
import java.util.*;
public class ArmstrongNumber3
{
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter any number");
int n = sc.nextInt();
int b = n;
int sum = 0;
int d = 0;
while (n != 0) {
d = n % 10;
sum += (d * d * d);
n = n / 10;
}
if (sum == b) {
System.out.println("Armstrong");
} else
{
System.out.println("Not Armstrong");
}
}
}
import java.util.Scanner;
public class Amstrong {
public static void main(String args[]) {
Integer num, temp, len = 0, initVal;
double finalVal = 0;
Scanner scn = new Scanner(System.in);
System.out.println("Enter the number");
num = scn.nextInt();
initVal = num;
temp = num;
while (temp != 0) {
temp = temp / 10;
len++;
}
for (int i = 0; i <= len; i++) {
temp = num % 10;
finalVal = finalVal + Math.pow(temp, len);
num = num / 10;
}
if (Double.valueOf(initVal) == finalVal) {
System.out.println("Amstrong");
} else {
System.out.println("Not Amstrong");
}
}
}
I'm trying to do the Algorithm programming assignment of Princeton , and I met a problem about the memory test. The assignment requires us run the percolation program N times and find the medium of the result, and I write a percolationtest.java and for each time, I create an instance variable, it worked, but use too much memory, and the instructor suggests me to use local variable, but I don't know how. Can some one help me and give me some advice, I really appreciate it.
public class PercolationStats {
private int N, T, totalSum;
private double []fraction;
private int []count;
public PercolationStats(int N, int T) {
if (N <= 0 || T <= 0)
throw new IllegalArgumentException();
else {
this.N = N;
this.T = T;
count = new int [T];
totalSum = N*N;
fraction = new double[T];
int randomX, randomY;
for (int i = 0; i < T; i++) {
Percolation perc = new Percolation(N);
while (true) {
if (perc.percolates()) {
fraction[i] = (double) count[i]/totalSum;
break;
}
randomX = StdRandom.uniform(1, N+1);
randomY = StdRandom.uniform(1, N+1);
if (perc.isOpen(randomX, randomY)) continue;
else {
perc.open(randomX, randomY);
count[i]++;
}
}
}
}
} // perform T independent experiments on an N-by-N grid
public double mean() {
double totalFraction = 0;
for (int i = 0; i < T; i++) {
totalFraction += fraction[i];
}
return totalFraction/T;
} // sample mean of percolation threshold
public double stddev() {
double u = this.mean();
double sum = 0;
for (int i = 0; i < T; i++) {
sum += (fraction[i] - u) * (fraction[i] - u);
}
return Math.sqrt(sum/(T-1));
} // sample standard deviation of percolation threshold
public double confidenceLo() {
double u = this.mean();
double theta = this.stddev();
double sqrtT = Math.sqrt(T);
return u-1.96*theta/sqrtT;
} // low endpoint of 95% confidence interval
public double confidenceHi() {
double u = this.mean();
double theta = this.stddev();
double sqrtT = Math.sqrt(T);
return u+1.96*theta/sqrtT;
} // high endpoint of 95% confidence interval
public static void main(String[] args) {
int N = 200;
int T = 100;
if (args.length == 1) N = Integer.parseInt(args[0]);
else if (args.length == 2) {
N = Integer.parseInt(args[0]);
T = Integer.parseInt(args[1]); }
PercolationStats a = new PercolationStats(N, T);
System.out.print("mean = ");
System.out.println(a.mean());
System.out.print("stddev = ");
System.out.println(a.stddev());
System.out.print("95% confidence interval = ");
System.out.print(a.confidenceLo());
System.out.print(", ");
System.out.println(a.confidenceHi());
}
}
public class Percolation {
private boolean[][] site;
private WeightedQuickUnionUF uf;
private int N;
public Percolation(int N) {
if (N < 1)
throw new IllegalArgumentException();
else {
site = new boolean[N + 2][N + 2];
for (int j = 1; j <= N; j++) {
site[0][j] = true;
site[N + 1][j] = true;
}
uf = new WeightedQuickUnionUF((N + 2) * (N + 2));
for (int i = 1; i <= N; i++) {
uf.union(0, i);
}
this.N = N;
}
}
public void open(int i, int j) {
if (i > N || i < 1 || j > N || j < 1)
throw new IndexOutOfBoundsException();
else {
if (!site[i][j]) {
site[i][j] = true;
if (site[i - 1][j]) {
uf.union((N + 2) * (i - 1) + j, (N + 2) * i + j);
}
if (site[i + 1][j]) {
uf.union((N + 2) * i + j, (N + 2) * (i + 1) + j);
}
if (site[i][j + 1]) {
uf.union((N + 2) * i + (j + 1), (N + 2) * i + j);
}
if (site[i][j - 1]) {
uf.union((N + 2) * i + (j - 1), (N + 2) * i + j);
}
}
}
}
public boolean isOpen(int i, int j) {
if (i > N || i < 1 || j > N || j < 1)
throw new IndexOutOfBoundsException();
else
return site[i][j];
}
public boolean isFull(int i, int j) {
if (i > N || i < 1 || j > N || j < 1)
throw new IndexOutOfBoundsException();
else
return site[i][j] && (i == 1 || uf.connected((N + 2) * i + j, 0));
}
public boolean percolates() {
for (int i = 1; i <= N; i++) {
if (this.isFull(N, i)) {
return true;
}
}
return false;
}
public static void main(String[] args) {
}
}
Added meanValue instance variable to keep mean value and replaced it in multiple places where you used to call mean() method which was over head to calculate again and again. Also modified "int[] count" as local variable which you were not using outside the constructor. post your "Percolation" and "StdRandom" classes for more optimization of code. you can run this code and test, it should reduce the runtime than yours.
public class PercolationStats {
private int N, T, totalSum;
private double []fraction;
private double meanValue;
public PercolationStats(int N, int T) {
if (N <= 0 || T <= 0)
throw new IllegalArgumentException();
else {
this.N = N;
this.T = T;
int [] count = new int [T];
totalSum = N*N;
fraction = new double[T];
int randomX, randomY;
for (int i = 0; i < T; i++) {
Percolation perc = new Percolation(N);
while (true) {
if (perc.percolates()) {
fraction[i] = (double) count[i]/totalSum;
break;
}
randomX = StdRandom.uniform(1, N+1);
randomY = StdRandom.uniform(1, N+1);
if (perc.isOpen(randomX, randomY)) continue;
else {
perc.open(randomX, randomY);
count[i]++;
}
}
}
}
}
// perform T independent experiments on an N-by-N grid
public double mean() {
double totalFraction = 0;
for (int i = 0; i < T; i++) {
totalFraction += fraction[i];
}
meanValue = totalFraction/T;
return meanValue;
} // sample mean of percolation threshold
public double stddev() {
double u = meanValue;
double sum = 0;
for (int i = 0; i < T; i++) {
sum += (fraction[i] - u) * (fraction[i] - u);
}
return Math.sqrt(sum/(T-1));
} // sample standard deviation of percolation threshold
public double confidenceLo() {
double u = meanValue;
double theta = this.stddev();
double sqrtT = Math.sqrt(T);
return u-1.96*theta/sqrtT;
} // low endpoint of 95% confidence interval
public double confidenceHi() {
double u = meanValue;
double theta = this.stddev();
double sqrtT = Math.sqrt(T);
return u+1.96*theta/sqrtT;
} // high endpoint of 95% confidence interval
public static void main(String[] args) {
int N = 200;
int T = 100;
if (args.length == 1) N = Integer.parseInt(args[0]);
else if (args.length == 2) {
N = Integer.parseInt(args[0]);
T = Integer.parseInt(args[1]); }
PercolationStats a = new PercolationStats(N, T);
System.out.print("mean = ");
System.out.println(a.mean());
System.out.print("stddev = ");
System.out.println(a.stddev());
System.out.print("95% confidence interval = ");
System.out.print(a.confidenceLo());
System.out.print(", ");
System.out.println(a.confidenceHi());
}
}
I'm relatively new to java, so I wouldn't be surprised if I'm missing something obvious here. Anyways, I made a code that finds the roots of a polynomial using the Bisection method. I thought the program was all well and dandy until I pasted it from notepad++ to command prompt, where I ended up getting a bunch of "class, interface, or enum expected" errors after compiling it using javac. Everything seems fine in the code itself, so I've deduced that I've made one of the following two errors: either something wrong occurred while I was copying and pasting into command prompt, or I actually did create an error in my code that I didn't catch. Could someone tell me just what I did wrong? It may be a minor fix, but I just don't know how to change it to get my code to work. Here's the code:
import java.util.*;
class Roots {
public static int degree;
public static double[] coArrayC;
public static double[] coArrayD;
public static int coeffVal;
public static void main( String[] args ){
double resolution = 0.01;
double tolerance = 0.0000001;
double threshold = 0.001;
double rightEndPt;
double leftEndPt;
int polyRootPointer = 0;
int diffRootPointer = 0;
boolean rootAns = false;
Scanner sc = new Scanner(System.in);
System.out.println();
System.out.print("Enter the degree: "); //prompts user to enter the correct degree of the polynomial
degree = sc.nextInt();
coeffVal = degree + 1; //the coefficient is one more than the number of degrees
System.out.print("Enter " + coeffVal + " coefficients: "); //adds in the value of the polynomial coefficient in to the line that prompts the user to specify which coefficients are in the function
double[] coefficients = new double[coeffVal]; //initialization of array, a bunch of doubles that represent the coefficients of the user's polynomial
coArrayC = new double[coeffVal]; //naming the array
double[] rootArray = new double[degree];//another array for the degrees of the polynomial
coArrayD = new double[coeffVal]; //and assigning it a name
for(int i = 0; i < coeffVal; i++) {
coefficients[i] = sc.nextDouble();
}
System.out.print("Enter the right and left endpoints, in that order: "); //prompts user to enter the interval limits
rightEndPt = sc.nextDouble();
leftEndPt = sc.nextDouble();
diff(coefficients); //calculates coefficients of derivative polynomial
for (double i = leftEndPt; i < rightEndPt-resolution; i = i + resolution){ //
if (isPositive(coArrayD, i) != isPositive(coArrayD, i+resolution) || isPositive(coArrayD, i) == 0) {
rootArrayDeriv[diffRootPointer] = findRoot(coArrayD, i, i+resolution, tolerance);
diffRootPointer++;
}
}
for (int i = 0; i < rootArrayDeriv.length; i++) {
double tempValue;
tempValue = poly(coefficients, rootArrayDeriv[i]);
tempValue = Math.abs(tempValue);
if (tempValue < threshold) {
rootArray[polyRootPointer] = rootArrayDeriv[i];
polyRootPointer++;
rootAns = true;
}
}
for (double i = leftEndPt; i < rightEndPt-resolution; i = i + resolution){
if (isPositive(coefficients, i) != isPositive(coefficients, i+resolution) || isPositive(coefficients, i) == 0) {
rootArray[polyRootPointer] = findRoot(coefficients, i, i+resolution, tolerance);
polyRootPointer++;
rootAns = true;
}
}
//Arrays.sort(rootArray); //sorts array from lowest to highest
if (rootAns == true) {
System.out.println("Sorry - no roots were found in the specified interval.");
}
}
} else {
for (int i = 0; i < rootArray.length; i++) {
if (rootArray[i] != 0.0) {
System.out.printf("Root found at %.5f\n :" Arrays.sort(rootArray[i])); //if roots are found, list them as an output, with five decimal places of accuracy
}
}
static double poly(double[] C, double x){
double polySum = 0;
coArrayC[0] = C[0];
for (int i = 1; i < coArrayC.length; i++){
coArrayC[i] = C[i]*(Math.pow(x, i)); //multiplies each coefficient by the designated power of X
}
for (int i = 0; i < coArrayC.length; i++){
polySum = polySum + coArrayC[i]; //accumulates the sum of of all the terms, after the coeff. were multiplied to their respective powers.
}
return(polySum);
}
static double[] diff(double[] C){
for (int i = 0; i < degree; i++){
coArrayD[i] = (i+1)*C[i+1]; //newly allocated array D containing coeff. of the polynomial that is the derivative of the polynomial with coeff. array C.
}
return(coArrayD);
}
static double findRoot(double[] C, double a, double b, double tolerance){ //using bisection method; similar to findRoot.java in cmps webpage.
double root = 0.0 , residual;
while ( Math.abs(b - a) > tolerance ) {
root = (a + b) / 2.0;
residual = poly(C, root);
if (poly(C, a) < 0 && poly(C, b) < 0) {
if (residual > 0)
b = root;
else
a = root;
} else if (poly(C, a) > 0 && poly(C, b) > 0) {
if (residual > 0)
a = root; //replace left endpoint
else
b = root; //replace right endpoint
}
}
return(root);
}
static int isPositive(double[] C, double a){
double endpointTempA;
endpointTempA = poly(C, a);
if (endpointTempA < 0) {
return(1);
} else if (endpointTempA > 0) {
return(2);
} else {
return(0);
}
}
}
You have two } too many here:
if (rootAns == true) {
System.out.println("Sorry - no roots were found in the specified interval.");
}
}
} else {
If you indent your code properly, it's easier to see these kinds of errors. Remove the two } that don't belong there:
if (rootAns == true) {
System.out.println("Sorry - no roots were found in the specified interval.");
} else {
There's also a missing , here, and you shouldn't pass a single double to Arrays.sort, but the whole array
System.out.printf("Root found at %.5f\n :"Arrays.sort(rootArray[i]));
Should be:
System.out.printf("Root found at %.5f\n :", Arrays.sort(rootArray));
And a missing }.
Instead of writing a whole program at once and then trying to compile it, write it little by little, and compile it each time you have for example a complete method. That way you avoid getting a mountain of little errors that confuse you.
I'm new to java and I'm trying to see if the method public String toString() is representing correctly the polynomial function. I don't know how to give the coefficients from main so that the class Func receives them.
package ro.utcluj.poo.lab04;
import java.util.Scanner;
class Func {
public double[] coef; //the coefficients
public int nrCoef; //coefficients number
public Func(double[] input)
{
nrCoef = input.length;
this.coef = new double[nrCoef];
for (int counter = 0; counter < input.length; counter++)
coef[counter] = input[counter];
}
public double getFuncValue(double x)
{
double exponent = nrCoef;
double y = 0;
double sum = 0;
for(int i = nrCoef; i >= 0; i--)
{
y = coef[i]*Math.pow(x, exponent-1); //n grade polynomial function
exponent--;
sum += y; //the sume for each member
}
return sum;
}
public double getDerivValue(double x)
{
double deriv = 0;
double rezDeriv = 0;
for(int i = 0; i < nrCoef - 1; i++)
{
deriv = coef[i]*(nrCoef - i)*Math.pow(x, nrCoef - i -1);
rezDeriv += deriv;
}
return rezDeriv;
}
public String toString()
{
String s = new String(" ");
int exp = nrCoef-1;
for(int i = 0; i < nrCoef; i++)
{
if(exp == 0 && coef[i] > 0)
s +="+" + coef[i];
else if(exp == 0 && coef[i] < 0)
s +=coef[i];
else if(exp == 1 && coef[i] > 0 && i == 0)
s +="+" + coef[i] + "x";
else if(exp == 1 && coef[i] >0)
s +="+" + coef[i];
else if(exp == 1 && coef[i] < 0)
s+=coef[i];
else if(coef[i] == 0)
s += "";
else if(coef[i] > 0 && i!=0)
s +="+" + coef[i]+"x^" + exp;
else
s +=coef[i] + "x^" + exp;
exp--;
System.out.println(s);
}
return s;
}
}
.
public class Main04 {
public static void main(String[] args) {
double[] v = new double[]{3,5,4};
Func f = new Func(v);
}
}
If you want to see what toString() does on your object f in main, all you need to do is
System.out.println(f);
f already has the coefficients that you passed into its constructor. println will call the object's toString() method and output the resulting string for you to see.
Also, as Steven pointed out in the comments, you don't need to put:
System.out.println(s);
in your toString() method itself. toString is supposed to produce and return the string. Your main method can deal with printing it out.
It's pretty simple to see what toString() does on object f in main...
You only have to yo use :
System.out.println(f);
This method will print the result of toString() to the command line.
That's all ;)
That worked but if I give the values {-3, -5, -4} I receive this:
-3.0x^2-5.0-4.0
It's missing the x from the second term(-5.0x). That is happining only if the second value is a negative one. For positive values it's working fine.
Try this way.
class Func {
public double[] coef; // the coefficients
public int nrCoef; // coefficients number
private StringBuilder sbl = new StringBuilder();
private StringBuilder tsbl = new StringBuilder();
public Func(double[] input) {
nrCoef = input.length;
this.coef = new double[nrCoef];
sbl.append("\nF(x) = ");
int exp = 0;
for (int counter = 0; counter < nrCoef; counter++) {
coef[counter] = input[counter];
if (coef[counter] != 0) {
if (counter != 0) {
sbl.append(coef[counter] < 0 ? " - " : " + ");
} else if (coef[counter] < 0) {
sbl.append(" - ");
}
exp = nrCoef - counter - 1;
sbl.append(Math.abs(coef[counter])+(exp == 0 ? "" : exp == 1 ? "*x" : "*x^"+exp));
}
}
}
public String toString() {
return tsbl.toString().isEmpty() ? sbl.toString() : tsbl.toString();
}
public double getFuncValue(double x) {
double sum = 0;
for (int index = 0; index < nrCoef; index++) {
sum += coef[index] * Math.pow(x, nrCoef - index - 1); // n grade polynomial
}
tsbl = new StringBuilder();
tsbl.append(sbl.toString());
tsbl.append("\nF(");
tsbl.append(x);
tsbl.append(") = "+sum);
return sum;
}
...
A positive number n is consecutive-factored if and only if it has factors, i and j where i > 1, j > 1 and j = i +1. I need a function that returns 1 if its argument is consecutive-factored, otherwise it returns 0.For example, 24=2*3*4 and 3 = 2+1 so it has the function has to return 1 in this case.
I have tried this:
public class ConsecutiveFactor {
public static void main(String[] args) {
// TODO code application logic here
Scanner myscan = new Scanner(System.in);
System.out.print("Please enter a number: ");
int num = myscan.nextInt();
int res = isConsecutiveFactored(num);
System.out.println("Result: " + res);
}
static int isConsecutiveFactored(int number) {
ArrayList al = new ArrayList();
for (int i = 2; i <= number; i++) {
int j = 0;
int temp;
temp = number %i;
if (temp != 0) {
continue;
}
else {
al.add(i);
number = number / i;
j++;
}
}
System.out.println("Factors are: " + al);
int LengthOfList = al.size();
if (LengthOfList >= 2) {
int a =al(0);
int b = al(1);
if ((a + 1) == b) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
}
Can anyone help me with this problem?
First check if its even, then try trial division
if(n%2!=0) return 0;
for(i=2;i<sqrt(n);++i) {
int div=i*(i+1);
if( n % div ==0) { return 1; }
}
return 0;
very inefficient, but fine for small numbers. Beyond that try a factorisation algorithm from http://en.wikipedia.org/wiki/Prime_factorization.
I have solved my problem with the above code. Following is the code.
public class ConsecutiveFactor {
public static void main(String[] args) {
// TODO code application logic here
Scanner myscan = new Scanner(System.in);
System.out.print("Please enter a number: ");
int num = myscan.nextInt();
int res = isConsecutiveFactored(num);
System.out.println("Result: " + res);
}
static int isConsecutiveFactored(int number) {
ArrayList al = new ArrayList();
for (int i = 2; i <= number; i++) {
int j = 0;
int temp;
temp = number % i;
if (temp != 0) {
continue;
}
else {
al.add(i);
number = number / i;
j++;
}
}
Object ia[] = al.toArray();
System.out.println("Factors are: " + al);
int LengthOfList = al.size();
if (LengthOfList >= 2) {
int a = ((Integer) ia[0]).intValue();
int b = ((Integer) ia[1]).intValue();
if ((a + 1) == b) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
}