How would i go about saving variables from a java program to be used the next the program is launched? I want to make games. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

How would i go about saving variables from a java program to be used the next the program is launched? I want to make games.

10th Mar 2018, 8:42 PM
Dawson Matthew
Dawson Matthew - avatar
3 ответов
+ 9
This would require use of files or databases. You could write to a file/database when the player saves, and/or implement autosaves, that trigger at certain times or events. Most games encrypt their savefiles or at least hide their extensions, but I wouldn't worry about that yet. There's three lessons on files here for Java. Here's the first one: https://www.sololearn.com/learn/Java/2186/ Keep in mind, if you want to practice in the Code Playground, you must keep recreating the file every time at the start of your program, before you work with it. The servers will not save your files.
10th Mar 2018, 8:59 PM
Tamra
Tamra - avatar
+ 6
Yes, you would, as well as how Java handles them, and whether to use local/external databases
10th Mar 2018, 9:35 PM
Tamra
Tamra - avatar
+ 1
when working with databases would I need to learn SQL?
10th Mar 2018, 9:20 PM
Dawson Matthew
Dawson Matthew - avatar