Jump to content

Variables in table

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Burgrave Sauerkraut

Burgrave Sauerkraut

    Newbie

  • Members
  • Pip
  • 1 posts
So there is code fragment:

	private boolean walking_left;

	private boolean walking_right;

	private boolean walking_up;

	private boolean walking_down;

	public boolean walking[] = {walking_right, walking_down, walking_left, walking_up};


I want to use boolean table for loops and single variables for 'if' statements, but when i set for example walking[0]=false i want variable walking_right to change too. How can i do it? I'm sure it's simple, but i'm kinda starting in programming so i appreciate help.

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
With booleans - or any primitive and Strings - you can't. You'll need to create a class which holds a boolean.
Then change the boolean in the object like walking[0].setFalse(), and then the original walking_right will have the boolean inside it changed as well.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users