When splitting a simple array using Java, how can I reference the specific values without using println?
I have a string separated by "||" - I want to manipulate that string such that I can call each half of it and assign each bit to a new string. If this was php I'd use list() or explode(), but I can't seem to get the variables to work.
I want to
- output the contents of each half of the temp array to the screen and
- join the portions together as
message = temp[0]+ "-"+ temp[1];doesn't seem to work.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
}
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.SENTMESSAGE);
//The string is (correctly) submitted in the format foo||bar
String delimiter = "||";
String[] temp = message.split(delimiter);
//??? How do I output temp[0] and temp[1] to the screen without using println?
//This gives me a single character from one of the variables e.g. f-
for(int i =0; i < temp.length ; i++)
message = temp[0]+ "-"+ temp[1];
//if I escape the above 2 lines this shows foo||bar to the eclipse screen
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
println? maybe useprint,printf,JOptionPane.showMessageDialog, etc?Stringinstead of e.g.Intent#putStringArrayListExtra(..)