Hi,
I am getting the following errors:
HelloWorldApp.java:54: <identifier> expected
public static Vector<int[]> breakTheMovementVector(int i,int j){
^
HelloWorldApp.java:102: ';' expected
}
^
2 errors
import java.io.*;
import java.util.*;
class HelloWorldApp {
public static void main(String[] args) {
try{
// Open the file that is the first
// command line parameter
String fname=args[0];
int x=0;
FileInputStream fstream = new FileInputStream(fname);
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine="",str1="";
//Read File Line By Line
while (x<2) {
// Print the content on the console
strLine = br.readLine();
x++;
if(x==1)str1=strLine;
if (x==2)
{
str1 = str1+" "+strLine;
}
// System.out.println (str1);
}
while ((strLine = br.readLine()) != null)
{
System.out.println (strLine);
}
StringTokenizer st = new StringTokenizer(str1);
st.nextToken();
String width=st.nextToken();
st.nextToken();
String height = st.nextToken();
//Close the input stream
System.out.print ("width ");
System.out.println (width);
System.out.print ("height is ");
System.out.println (height);
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
//BreaktheMovement Vector
public static Vector<int[]> breakTheMovementVector(int i,int j){
Vector<int[]> result=new Vector<int[]>();
int signOfI;
int signOfJ;
double ii=new Double(Math.abs(i));
double jj=new Double(Math.abs(j));
if(i==0 && j==0)
return result;
if(i>0) signOfI=1; else signOfI=-1;
if(j>0) signOfJ=1; else signOfJ=-1;
if (j==0){
for (int f=0;f<ii;f++){
int[] point={signOfI,0};
result.add(point);
}
return result;
}
if (i==0){
for (int f=0;f<jj;f++){
int[] point={0,signOfJ};
result.add(point);
}
return result;
}
Double a=1.0;
Double b=1.0;
double cross=((ii/jj)*(a-.5)+.5);
while (b<=ii || a<=jj){
if (b>cross){
int[] point={0,signOfJ};
result.add(point);
a++;
cross=((ii/jj)*(a-.5)+.5);
}else if (b==cross){
int[] point={signOfI,signOfJ};
result.add(point);
a++;
b++;
cross=((ii/jj)*(a-.5)+.5);
}else if (b<cross){
int[] point={signOfI,0};
result.add(point);
b++;
}
}
return result;
}
}