Homework help
Moderator: Coders of Rage
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Sun Aug 31, 2008 8:44 pm
Homework help
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;
}
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
You're missing the second half of the first instruction
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Sun Aug 31, 2008 8:44 pm
Re: Homework help
I'm actually quite proud of myself for figuring that out before looking at this :P
-
- Chaos Rift Junior
- Posts: 209
- Joined: Thu Feb 12, 2009 8:46 pm
Re: Homework help
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:
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.
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;
The Java Tutorials offers guides and examples to help Java programmers.
- davidthefat
- 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
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... Just put the main
-
- Chaos Rift Newbie
- Posts: 2
- Joined: Wed Sep 08, 2010 2:44 am
Re: Homework help
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.
- cypher1554R
- Chaos Rift Demigod
- Posts: 1124
- Joined: Sun Jun 22, 2008 5:06 pm
Re: Homework help
Are you googling "forum homework" and registering to give opinions on every homework on this planet?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.
Re: Homework help
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.
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"
Dad, "Yea well I have a fan belt in street fighting"
- hurstshifter
- 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
Wut book? tHat liek teevee?avansc wrote:Do people not read books anymore?
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
http://www.thenerdnight.com
- GroundUpEngine
- 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
!hurstshifter wrote:Wut book? tHat liek teevee?avansc wrote:Do people not read books anymore?
- TheAustech
- 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
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.
-
- Chaos Rift Newbie
- Posts: 1
- Joined: Fri Oct 01, 2010 12:55 am
Re: Homework help
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.
- EccentricDuck
- 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
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...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.
And realized that Chaos Rift is being spammed by bots that are spewing out bullshit.
What's up with all these bots anyways?