Problem with LinkedList
hi, everyone. i have a problem with writing from a list. i've one such as
LinkedList list =new LinkedList();
list.add("one");
list.add("two");
System.out.println(list);
so i'm achieving such as that:
[one,two]. is there any way to achieve such as that:
one, two <without those brackets?please for any help,
king regards
You are getting that beacuse you are printing the list itself. Try using a loop and going through the whole list using the get method see below:
LinkedList<String> list = new LinkedList<String>();
list.add("one");
list.add("two");
System.out.println(list);
for(String listVal : list){
System.out.print(listVal+ " ");
}
i've tried it it works, thanks but one more thing from antoher subject:
i have string: "abracadabra"
now i'm checking if my string has "abra"
if(string.indexOf("what should i put here")>-1) then....
what should i put there, i'm too good in regex, thanks for advice
> i've tried it it works, thanks but one more thing
> from antoher subject:
>
> i have string: "abracadabra"
>
> now i'm checking if my string has "abra"
> > if(string.indexOf("what should i put here")>-1)
> then....
>
>
> what should i put there, i'm too good in regex,
> thanks for advice
Are you checking whether the beginning of the string has "abra" or whether "abra" is anywhere in the string?