我希望它能让用户告诉我的代码,当某个变量具有某个值时,它应该执行某些操作。我已经写了一个简单的代码示例,我希望你能看到它,我希望你能理解它。以任何方式制作String并让Java检查具有相同名称的变量是否等于另一个变量的值。
int turn = 1;
String variable = "turn";
int compareToThisValue = 1;
if (variable.toVariable() == compareToThisValue) {
System.out.println("Yes it works thank you guys!");
{
答案 0 :(得分:2)
我想以下代码可以提供帮助。它使用java Reflection来完成工作。如果您有其他一些要求,可以进行调整。
ERROR in ./node_modules/graphql/index.mjs
88:0-148:42 Can't reexport the named export 'typeFromAST' from non EcmaScript module (only default export is available)
@ ./node_modules/graphql/index.mjs
@ ./src/schemas/index.ts
@ ./server.ts
ERROR in ./node_modules/graphql/index.mjs
88:0-148:42 Can't reexport the named export 'valueFromAST' from non EcmaScript module (only default export is available)
@ ./node_modules/graphql/index.mjs
@ ./src/schemas/index.ts
@ ./server.ts
ERROR in ./node_modules/graphql/index.mjs
88:0-148:42 Can't reexport the named export 'valueFromASTUntyped' from non EcmaScript module (only default export is available)
@ ./node_modules/graphql/index.mjs
@ ./src/schemas/index.ts
@ ./server.ts
ERROR in C:\Users\houssem\Projects\ctc\services\affairs\src\schemas\index.ts
./src/schemas/index.ts
[tsl] ERROR in C:\Users\houssem\Projects\ctc\services\affairs\src\schemas\index.ts(5,28)
TS2307: Cannot find module './affairs.gql'.
ERROR in C:\Users\houssem\Projects\ctc\services\affairs\services\database\engineer.ts
./services/database/engineer.ts
[tsl] ERROR in C:\Users\houssem\Projects\ctc\services\affairs\services\database\engineer.ts(7,19)
TS2307: Cannot find module './engineer.sql'.
.
.
.
.
.