Click here to Skip to main content
14,326,100 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a String []
called Contents that contains 3 elements 10 20 20

what I'm trying to do is this
Contents[3] = 10 20 30  


I'm new to java

so what I want to do is get these elements into separate variables like
Contents[3].1st element = Start
Contents[3].2nd element = Stop
Contents[3].3rd element = Go

What I have tried:

I tried all kinds of stuff with no luck
such as
String [] test = Contents[3]
Posted
Updated 12-Apr-16 11:18am
v2
Comments
Kornfeld Eliyahu Peter 12-Apr-16 15:57pm
   
Pick a basic book about Java (and programming in general) and read it...
Patrice T 12-Apr-16 16:48pm
   
Don't post multiple time the same question.
Rate this:
Please Sign up or sign in to vote.

Solution 3

As Oracle states in Java tutorial[^]:
Quote:
An array is a container object that holds a fixed number of values of a single type.

// allocates memory for 10 integers
anArray = new int[10];

// initialize first element
anArray[0] = 100;
// initialize second element
anArray[1] = 200;
// and so forth
anArray[2] = 300;
anArray[3] = 400;
anArray[4] = 500;
anArray[5] = 600;
anArray[6] = 700;
anArray[7] = 800;
anArray[8] = 900;
anArray[9] = 1000;



According to above example:
int Contents = new int[3];
Contents[0]=10;
Contents[1]=20;
Contents[2]=30;

int var1 = Contents[0];
int var2 = Contents[1];
int var3 = Contents[2];


Please, get down to study. Start by buying good book.
   
Comments
Sergey Alexandrovich Kryukov 12-Apr-16 18:50pm
   
Sure, 5ed. I would add: no need to buy a book on paper and spend any money.
—SA
Maciej Los 13-Apr-16 1:51am
   
Thank you, Sergey.
Rate this:
Please Sign up or sign in to vote.

Solution 1

Go to The Java Tutorials[^] and you will find the answers.
   
Comments
Kornfeld Eliyahu Peter 12-Apr-16 16:22pm
   
Come-on!!! Since when one have to learn programming, to write an application...There is CP for that!!!
:-)
Richard MacCutchan 12-Apr-16 16:41pm
   
Sad how many people think that is true.
Sergey Alexandrovich Kryukov 12-Apr-16 18:50pm
   
It's really sad and threatening. :-)
My 5.
—SA
Rate this:
Please Sign up or sign in to vote.

Solution 2

This is not the way one learn a language.
Read documentation, follow tutorials.
Google is your friend.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100