How to solve error: ';' expected in Java? -
i have error: ';' expected
issue java code below. don't know how solve it?
sortthread
, mergethread
have been created class, , compiled well.
the problem
sortthread t1.join() = new sortthread(a); sortthread t2.join() = new sortthread(b); mergethread m.start() = new mergethread(t1.get(),t2.get());
these 3 line codes has error: ';' expected
issues.
in main, create 2 array, , b. m array merge a&b, , main display m.
any hints or solutions helpful me.
import java.util.random; public class main{ public static void main(string[] args){ random r = new random(system.currenttimemillis()); int n = r.nextint(101) + 50; int[] = new int[n]; for(int = 0; < n; i++) a[i] = r.nextint(100); n = r.nextint(101) + 50; int[] b = new int[n]; for(int = 0; < n; i++) b[i] = r.nextint(100); sortthread t1.join() = new sortthread(a); sortthread t2.join() = new sortthread(b); mergethread m.start() = new mergethread(t1.get(),t2.get()); system.out.println(arrays.tostring(m.get())); } }
you can't call methods before finish initializing variables you're calling.
sortthread t1.join() = new sortthread(a); sortthread t2.join() = new sortthread(b); mergethread m.start() = new mergethread(t1.get(),t2.get());
should like
sortthread t1 = new sortthread(a); t1.start(); // <-- want start before join. sortthread t2 = new sortthread(b); t2.start(); t1.join(); t2.join(); mergethread m = new mergethread(t1.get(),t2.get()); m.start(); m.join();
Comments
Post a Comment