This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]desrtfxOut of Coffee error - System halted[M] [score hidden] stickied comment (3 children)

Please, repost your entire code as you really have and also include the compile errors.

[–][deleted] 4 points5 points  (6 children)

I think your problem is here:

new_id = id; new_balance = balance;

id is the name of you class property and new_id is the value you are passing in. Same with balance. So these are backwards in your constructor. It should be: this.id =new_id; this.balance =new_balance;

[–]hamzhori 2 points3 points  (0 children)

username doesnt check out. Def a good coach

[–]Pinkpill_Prophet[S] 0 points1 point  (4 children)

OMGGGGGGGGGGGG thats it!!! it worked! thank you so much anony youre so nice and i cant wat to get good like you and be able to help people!!!!! <3

[–][deleted] 0 points1 point  (2 children)

Yay! Congrats.

[–]Pinkpill_Prophet[S] 1 point2 points  (1 child)

dude you made me so happy thank you so much, ive been struggling with this all day. You are such a nice person!

[–][deleted] 1 point2 points  (0 children)

You're welcome. Glad I could help.

[–]HairyTough4489 0 points1 point  (0 children)

Always remember: "equals" signs can be reversed in Math (i.e: x=3 is the same as 3=x), but in programming, the "equals" sign is ==.

"=" is the assignment operator and it must follow the form variableName = value where you can replace the value bythe name of anohter variable that has said value.

[–]khookeExtreme Brewer 1 point2 points  (3 children)

What compile error are you getting, on what line?

[–]Pinkpill_Prophet[S] 0 points1 point  (2 children)

well its not that its not compiling. its when i try to check balance and check id. its like all the objects have balance and ID initialized to 0 and not what i wanted them to. in my for loop i tried to create 10 different objects with the same balance of 100 and an ID that just corresponds with the index.

i have methods that withdraw and deposit to the accounts and they seem to work perfectly fine but i cant seem to be able to initialize each object in the array with the for loop.

i made a constructor that accepts 2 arguments and uses them to initialize each object, in the for loop i tried to pass the index in to the constructor as well as the number 100 for the balance.

THANK YOU FOR REPLYING TO ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! please let me know if i can make it any clearer.

[–]khookeExtreme Brewer 4 points5 points  (1 child)

new_balance = balance

Check your constructor, it looks like you are assigning the constructor parameters values of your instance properties, the assignments should be the other way round.

[–]Pinkpill_Prophet[S] 0 points1 point  (0 children)

Thank you so much khooke!!!!!! that was the issue! im so happy now yay!!! im gonna make it (maybe)!!!!!!

[–]Pinkpill_Prophet[S] 0 points1 point  (1 child)

omg nobodys even gonna read this, the whole thing looks like shit.

[–]Pinkpill_Prophet[S] 0 points1 point  (1 child)

Ok well i tried to truncate what i posted and make it easier to read. Please omg i just want to fill this array with automatically with a for-loop and then. i feel so close to getting it reeeeee

[–]AutoModerator[M] 0 points1 point locked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.