Homework help

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
villeballa89
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Sun Aug 31, 2008 8:44 pm

Homework help

Post 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;

}
Scoody
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Fri Feb 06, 2009 2:07 pm

Re: Homework help

Post by Scoody »

You're missing the second half of the first instruction :)
villeballa89
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Sun Aug 31, 2008 8:44 pm

Re: Homework help

Post by villeballa89 »

I'm actually quite proud of myself for figuring that out before looking at this :P
wearymemory
Chaos Rift Junior
Chaos Rift Junior
Posts: 209
Joined: Thu Feb 12, 2009 8:46 pm

Re: Homework help

Post 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.
User avatar
davidthefat
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 529
Joined: Mon Nov 10, 2008 3:51 pm
Current Project: Fully Autonomous Robot
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: California
Contact:

Re: Homework help

Post 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
cristine27
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 2
Joined: Wed Sep 08, 2010 2:44 am

Re: Homework help

Post 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.
User avatar
cypher1554R
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1124
Joined: Sun Jun 22, 2008 5:06 pm

Re: Homework help

Post 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? :)
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Homework help

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
hurstshifter
ES Beta Backer
ES Beta Backer
Posts: 713
Joined: Mon Jun 08, 2009 8:33 pm
Favorite Gaming Platforms: SNES
Programming Language of Choice: C/++
Location: Boston, MA
Contact:

Re: Homework help

Post by hurstshifter »

avansc wrote:Do people not read books anymore?
Wut book? tHat liek teevee?
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: Homework help

Post by GroundUpEngine »

hurstshifter wrote:
avansc wrote:Do people not read books anymore?
Wut book? tHat liek teevee?
! :lol:
User avatar
TheAustech
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 96
Joined: Fri Sep 03, 2010 4:38 pm
Current Project: BeatTapper
Favorite Gaming Platforms: PC
Programming Language of Choice: C++, C#
Location: Maryland
Contact:

Re: Homework help

Post 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
patricia39
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 1
Joined: Fri Oct 01, 2010 12:55 am

Re: Homework help

Post 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.
Last edited by patricia39 on Mon Oct 11, 2010 1:05 pm, edited 2 times in total.
User avatar
EccentricDuck
Chaos Rift Junior
Chaos Rift Junior
Posts: 305
Joined: Sun Feb 21, 2010 11:18 pm
Current Project: Isometric "2.5D" Airship Game
Favorite Gaming Platforms: PS2, SNES, GBA, PC
Programming Language of Choice: C#, Python, JScript
Location: Edmonton, Alberta

Re: Homework help

Post 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? ;)
Post Reply