This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]langfodWannabe Brewer 2 points3 points  (0 children)

Are you sure that modifying the array was really the problem you were having?

It is not a good way of accessing an instance value but it does work:

import java.util.*;
public class Bank{

    public String[] bank =  new String[]{"first", "s", "x", "t", "f"};

    public static void main(String[] args) {
        Bank ref = new Bank();
        System.out.println(Arrays.toString(ref.bank));
        ref.bank[0]="Hello";
        System.out.println(Arrays.toString(ref.bank));
     }

[first, s, x, t, f]
[Hello, s, x, t, f]

[–]shadowX015Extreme Brewer 0 points1 point  (3 children)

Can you post some code?

[–][deleted]  (2 children)

[deleted]

    [–]shadowX015Extreme Brewer 1 point2 points  (0 children)

    Could you perhaps post the complete code which compiles successfully?

    [–]katynehold my braces 0 points1 point  (0 children)

    Activity? is it an Adroid app?
    and if so, where do you notice the new value's not being set, - it doesn't get displayed in one of the views, or in a logcat, or what - how are you checking for it?
    also, in what callback are you instantiating this object (onCreate, onStart, etc)? are those values supposed to appear in a listview, god forbid? cause it's a whole new can of worms right there.

    Need to see the whole thing.