welocome to javaranch Dwen.
it will run ofcourse their must be a problem with otherpart in your code.can you please post your complete code along with compiler message,then it will be better to sortout.

and please donot mention your query in the quotes also you have edited the quote of dwen hal.please keep it in mind next time.

Try to enjoy your work while doing it,it will Automatically convert in Hard Work...

Dwen Hal

Greenhorn

Posts: 5

posted 1 year ago

The ";" its not the problem its just a simple code that I did here, here is peace of code from my code:

Dave Tolls

Ranch Foreman

Posts: 3061

37

posted 1 year ago

That's different.
That Math.pow() is not an assignment so is not allowed outside of a code block.

Dwen Hal

Greenhorn

Posts: 5

posted 1 year ago

Dave Tolls wrote:That's different.
That Math.pow() is not an assignment so is not allowed outside of a code block.

here you will get the error identifier expected since in order to perform Math.pow(a,3) it needs some identifier either variable or method so that you can perform the operation via accesing a variable or calling a method.think about it why have you declared Math.pow(a,b)?

Try to enjoy your work while doing it,it will Automatically convert in Hard Work...

...Tolls does victory dance that many might mistake for Dad Dancing...

Campbell Ritchie

Marshal

Posts: 56546

172

posted 1 year ago

praveen kumaar wrote:. . . it will run ofcourse . . . .

Not the first piece of code, which has a statement outside methods and constructors. That code will not compile because statements must be in side methods constructors, etc. You cannot write a statement simply in the class.
The statements shown, e.g. Math.pow(a, 3);, have no effect because their return values are not used; they simply disappear into cyber‑limbo never to be seen again. Also you sh‍ould probably not use pow for small integer arguments; the following will probably be faster:-
a * a * a