Похожие чаты

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 ответов

40 просмотров
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

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта