Похожие чаты

Hi, I want to create a vector of strings, set

the (0) element to something and print it out. Why do i get an error?


Vector<String> string = new Vector<>();
string.get(0) = "some string";
System.out.println(string.get(0));

The error: Variable expected

12 ответов

24 просмотра
Rastin- Автор вопроса

I also tried using the set() method: Vector<String> string = new Vector<>(); string.set(0, "sss"); I get Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0

asking this, it's kind of "WTF" ... It seems you missed out java basic knowledge.

Rastin- Автор вопроса
Mihai
asking this, it's kind of "WTF" ... It seems you ...

Yes, I'm new to java. and I need to use vectors. Since it's such a basic question, just give me a simple answer, I don't think it would take more than a couple minutes of your time.

Rastin
Yes, I'm new to java. and I need to use vectors. ...

I have time, but I won't give you any tip about the error since the error is so easy to fix, I let you find it by your own. 🤷‍♂

Rastin- Автор вопроса
Rastin- Автор вопроса
Mihai
I have time, but I won't give you any tip about th...

Well, you could've just answered the question instead of wasting your precious time on arguing about it tnx anyway

Rastin- Автор вопроса
Rastin- Автор вопроса
Mihai
🤔

i thought Array and ArrayList are the same

Rastin
I also tried using the set() method: Vect...

First of all, read what vector, array and arraylist is in java. But to answer the question. Your array contains no elements. Im assuming you come from a language where initialization happens at variable creation time... welcome to java, where almost everything is a pointer

Похожие вопросы

Обсуждают сегодня

а через ESC-код ?
Alexey Kulakov
29
30500 за редактор? )
Владимир
47
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
any reference of this implementation?
BitBuddha
29
Ⓐrtto, [4/23/24 7:02 PM] Please explain more fully how it is not working exactly, and what are the steps you are taking, and what error messages come or what happens. Ⓐrtto, ...
Ezza Kezza
2
sounds like people have lost their kaspa on tradeogre... does this mean tradeogre not trustworthy?
Ezza Kezza
15
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
So much speculation in the last week. So much volatility in price. This is because Hedera has a GC that isn't using the network it's governing. Why aren't people asking why a...
Summit Seeker R
9
Карта сайта