I've been working on a project and am in the process of coding the app (in Java) and I was wondering if there was a way I could have an outside object show that a switch has been flipped(like a toy for the sake of this example) l. Like if I turned on 'switch 1' on the toy the apps own button would switch to on and vice versa. I'm sure there is a way but I'm just unsure as to what hardware I'd need and what the code would look like.
Thank you very much.
This is a very broad question. The simple answer is yes: you can control objects like toys from computers (and thus from Java).
Try searching for "computer controlled toy" or "control light from computer".
Here is a university course that describes controlling a small robot with Java: http://programming.sdarobotics.org/robot-java/
Here are some toys that are designed to be easy to program: https://www.fatherly.com/gear/best-robot-toys/