Answer the question
In order to leave comments, you need to log in
JAVA How to get variable value from for?
How to pass each numberS value from the send method?
These are buttons for telegrams, they are formed by the for loop. I want them to update the record in the database on click, for this I want to pass the value of the numberS variable. How to do it right?
public void send(){
String[] greportsArr = new String[greportsL.size()];
greportsArr = greportsL.toArray(greportsArr);
for(int i = 0; i < numL.size(); i++){
numberL = numL.get(i);
String reportsL = greportsArr[i];
String[] numLArr = new String[numL.size()];
numLArr = numL.toArray(numLArr);
numberS = numLArr[i];
for(int it = 0; it < userids.size(); it++){
String userid = userids.get(it);
------
inlineKeyboardButton1.setText(numberS);
inlineKeyboardButton1.setCallbackData("Agree");
----
System.out.println(numberS); // тут значение еще верное
try {
execute(message);
} catch (TelegramApiException e) {
e.printStackTrace();
}
} }
}
public void onUpdateReceived(Update update) {
----
} else if (update.hasCallbackQuery()) {
String call_data = update.getCallbackQuery().getData();
long message_id = update.getCallbackQuery().getMessage().getMessageId();
long chat_id = update.getCallbackQuery().getMessage().getChatId();
System.out.println(numberS); // тут уже приходит последнее значение в массиве.
if (call_data.equals("Agree")) {
Login lgc = new Login();
lgc.updateQ(numberS);
String answer = "Согласовано";
Answer the question
In order to leave comments, you need to log in
You
System.out.println(numberS); // тут значение еще верное
output in a loop, andSystem.out.println(numberS); // тут уже приходит последнее значение в массиве.
in a completely different way. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question