Page 1 of 1

Homework help

Posted: Tue Sep 07, 2010 1:01 am
by villeballa89
So I'm taking Java this semester and my professor doesn't really cover much of the how to part of the language. Was looking for a little help. Here's the assignment:
Instructions:
Create a Java class, named Homework1, and a main method.
Create a String literal, s, with the value of "Hello World";
Create an int, i, with the value 10;
Create an Integer literal, i2, with the value of 11;
Reassign the i2 with i.

I've figured out how to do everything but the bold portion. Wondering if anyone can tell me what I'm doing wrong and why its wrong? here's the code.


public class Homework1 {
String s = "Hello World";
int i = 10;
Integer i2 = 11;

i2 = i;

}

Re: Homework help

Posted: Tue Sep 07, 2010 2:06 am
by Scoody
You're missing the second half of the first instruction :)

Re: Homework help

Posted: Tue Sep 07, 2010 4:02 am
by villeballa89
I'm actually quite proud of myself for figuring that out before looking at this :P

Re: Homework help

Posted: Tue Sep 07, 2010 3:27 pm
by wearymemory
If your problem has been solved, please edit the title to include the word "solved." The use of code tags promote readability and clarity in your code, so you should make use of them in the future.

Expression statements like i2 = i cannot be directly stated within the body of a class.

The following valid expressions declare member variables:

Code: Select all

String s = "Hello World";
int i = 10;
Integer i2 = 11;
However, it may be more appropriate to place your expressions within a main method, which you have not yet created.

The Java Tutorials offers guides and examples to help Java programmers.

Re: Homework help

Posted: Tue Sep 07, 2010 11:09 pm
by davidthefat
You didn't make a main function, Java is stupid, so it will get error when trying to run it cause it does not know if you have a main... Or does it know that you don't have a main and it tells you as a compiler error... :lol: Just put the main

Re: Homework help

Posted: Wed Sep 08, 2010 2:57 am
by cristine27
As an Information Technology graduate, my school did not give me the chance to study Java because they changed our school curriculum. So with regards to your homework, I think it is better if you will study through online tutorials about java. You can learn not only about your assignment but more about java.

Re: Homework help

Posted: Wed Sep 08, 2010 4:02 am
by cypher1554R
cristine27 wrote:As an Information Technology graduate, my school did not give me the chance to study Java because they changed our school curriculum. So with regards to your homework, I think it is better if you will study through online tutorials about java. You can learn not only about your assignment but more about java.
Are you googling "forum homework" and registering to give opinions on every homework on this planet? :)

Re: Homework help

Posted: Wed Sep 08, 2010 7:35 am
by avansc
Do people not read books anymore?

Also, davidthefat, you don't have to have a main in a java source file to compile it, but you do to run it, just like C/++/pascal/**, or whatever language that needs a main entry, and java will be nice enough to let you know there is no main.

Re: Homework help

Posted: Wed Sep 08, 2010 8:53 am
by hurstshifter
avansc wrote:Do people not read books anymore?
Wut book? tHat liek teevee?

Re: Homework help

Posted: Wed Sep 08, 2010 3:26 pm
by GroundUpEngine
hurstshifter wrote:
avansc wrote:Do people not read books anymore?
Wut book? tHat liek teevee?
! :lol:

Re: Homework help

Posted: Wed Sep 08, 2010 4:32 pm
by TheAustech
avansc wrote:Do people not read books anymore?

Also, davidthefat, you don't have to have a main in a java source file to compile it, but you do to run it, just like C/++/pascal/**, or whatever language that needs a main entry, and java will be nice enough to let you know there is no main.

They're called Kindles dude.
Image

Re: Homework help

Posted: Fri Oct 01, 2010 1:09 am
by patricia39
Your homework is the very first and basic activity we did on our java subject when I was still studying. We searched the codes through internet and we were able to finish it successfully. Thank God we passed the subject.

Re: Homework help

Posted: Fri Oct 01, 2010 1:45 pm
by EccentricDuck
patricia39 wrote:Your homework is the very first and basic activity we make on out java subject. What we do is to research the codes through internet. And thank God we passed.
Indeed, thank the gods we have passed, for the researching of the codes on the interwebz told us of the invasion... the bots would rain down upon us like hellfire and brimstone. If it were not for homework being the very first and basic activity we make on out java subject, we would never have researched the codes...
And realized that Chaos Rift is being spammed by bots that are spewing out bullshit.

What's up with all these bots anyways? ;)