ユーザーが式を入力します。ユーザーが入力として次のように入力したとします。
new y java.util.ArrayList int:5
文字列のトークン化に成功し、文字列配列の別の場所に格納しました。次にやりたいことは、インデックスの内容を確認し、上記のリフレクションの入力に記載されているとおりに行うことです。やり方に困っています。ここに私のコードがあります
public static void handling_input()
{
System.out.println("Welcome To Java Command Prompt: ");
aLine = null;
try
{
System.out.println("Enter The Command Line Expression: ") ;
keyboard = new BufferedReader(new InputStreamReader(System.in));
aLine = keyboard.readLine();
st = new StringTokenizer(aLine);
dt = new StringTokenizer(aLine);
}
catch (IOException ex)
{
System.out.println("Error reading input!");
}
}
public static void storing_tokens()
{
int counter =0;
while(st.hasMoreTokens())
{
counter++;
st.nextToken();
}
int i=0;
expression_keeper= new String[counter];
do
{
expression_keeper[i] = dt.nextToken().toString();
i++;
}while(dt.hasMoreTokens());
}
public static void token_classification()
{
for(int i=0; i<expression_keeper.length; i++)
{
if(expression_keeper[0].equalsIgnoreCase("new"))
{
}
else
if(expression_keeper[0].equalsIgnoreCase("call"))
{
}
else
if(expression_keeper[0].equalsIgnoreCase("print"))
{
}
else
{
System.out.println("Invalid Script!");
}
}
}
}
このif条件の中で:
if(expression_keeper[0].equalsIgnoreCase("new"))
{
}
指定されたクラス、そのオブジェクトを作成し、言及された修飾子に値を割り当てたい!