• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Update! More help? Java homework. I'm getting pissed

IronOxide

Senior member
I can't figure out how to get a number raised to a variable power. 2^x doesn't work, and I couldn't find anything on the api. Anyone that knows java wanna help? Thanks!
 
I never quite understood the purpose of a for loop/ for while loop ect..

Just one of those things I want to figure out before even reading a java book.
 
Originally posted by: Regs
I never quite understood the purpose of a for loop/ for while loop ect..

Just one of those things I want to figure out before even reading a java book.

In english, a for loop says

given x variable, while a comparison of x is true, do whats in the brackets and then do this line

For(Int variable = 1; variable != 2; variable++)
{
cout << "See, I'm not so hard to understand" << endl;
}

The program hits the for, and does the first part of the paren (Int variable = 1😉 in this case, it defines an integer variable and sets it equal to 1.

Then it checks if the second is true. variable != 2. variable == 1 and 1 < 2 so this is true. So the program executes what's in the squigglies (cout << "See, I'm not so hard to understand." << endl😉 and then the last item in the parens (variable++).

The program then checks the second part again. It's false this time, so the loop terminates.

It really makes more sense if you play with it in a debugger. You can watch exactly how the language steps through each part, and why.
 
Thanks you guys, I knew you guys could help me out. I got one more question though (at least for now). How do I convert a string to an int? Isn't it mystring.parseint() or something?
 
Originally posted by: IronOxide
Thanks you guys, I knew you guys could help me out. I got one more question though (at least for now). How do I convert a string to an int? Isn't it mystring.parseint() or something?

string s="535";
int i = Integer.parseInt(s);

doubles would be...
Double.parseDouble(string s);

same story for Float and Long too.
 
Java 2 Platform API

This site might come in handy, it sure did for me last year in high school, covers all the classes, and libraries that you'd ever use, just it won't help you if you're going to be using 1.4 API calls.. since it's the 1.3 API Documentation.

Just search up a class, and then check the methods and all.

Hope this helps,

--Mark
 
Back
Top