0

Is there a way to store a variable in Java without losing it even after stopping the program without using files or databases ?

13th Jul 2017, 10:33 PM
ilyes younes
ilyes younes - avatar
5 odpowiedzi
+ 2
Well if your exit code counts, then you can pass an exit code to the calling process which can forward it to the next. But what'd be the use case?
13th Jul 2017, 10:52 PM
Jamie
Jamie - avatar
+ 2
If you end your program, the memory it's using gets deallocated. So for that purpose, no. You could just store them in a file with encryption to stop users tampering, eg: scores.dat random data #1 random data #2 random data random data #3 #4 random data #5 random data ...then encrypt it. I assume tampering is the reason.
13th Jul 2017, 11:59 PM
Jamie
Jamie - avatar
+ 1
i will try to do it with files thanks Jamie
14th Jul 2017, 12:14 AM
ilyes younes
ilyes younes - avatar
0
I want to store variables in my program as a scores of players and keep them stored and refer to it later and display there values
13th Jul 2017, 11:11 PM
ilyes younes
ilyes younes - avatar
0
You can serialize classes and deserialize them later. That would be a more advanced topic though...
15th Jul 2017, 7:50 PM
marit vandijk