The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

question about indexes

So I was wondering if it is possible to stores indexes as variables. I have a question where the user inputs a string such as the fox [who is red] must have left earlier.
The problem is to return only what is in the [] including the brackets and the second question is to get the length of that part. Does anyone know how to do this? I was figuring if I could store the indexOf [ and the lastIndexOf ] stored those values as variables and then used them in a substring method (a,b) but I don't know how to do that or if it's even possible. Thanks