简体   繁体   中英

Is there any other shorter method to to pass values at compile time in java other then using Scanner class and Command line?

我正在探索在编译时可以在 java 中传递值的方法。所以我突然想到,除了使用 Scanner 类和命令行之外,还有没有其他方法可以在 java 程序的编译时传递值。

From what I know:

No, not really.

Java has this "helpful" feature that when you compile, no other input is accecpted unless it's console inputs (Command line arguments) or java.util.scanner OR equivalent. There really isn't any other way to give the code something to work with.

However, there is also System.currentTimeMillis() , but that uses time as an input, so if there is a way to adapt your code around using constantly-updating times in milliseconds, i'll count that as another way to pass values into java.

Other that that, no.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM