I have to write a function that prepends if boolean is true or append if boolean is false a string to an array. I'm not exactly sure what this means? Do I just add a string to the first element of the array if I'm prepending or add a string to the last element of the array if I'm appending? Or what?
-
1Question isn't that clear but since this is homework you should ask some doubts to your proff. or teacher and get it clarified.A_Var– A_Var2010-10-09 21:16:28 +00:00Commented Oct 9, 2010 at 21:16
-
It sounds to me like you are supposed to write a function which takes a boolean flag. However, the assignment itself is ambiguous. It hasn't clearly described what you're supposed to append/prepend the string to.Matt Ball– Matt Ball2010-10-09 21:20:31 +00:00Commented Oct 9, 2010 at 21:20
Add a comment
|
3 Answers
You could user StringBuilder instead of using array and just append ur string at the first of the stringBulder . E.g: StringBuilder str = new StringBuilder(); str.append("everyBody"); str.insert(0, "hello "); System.out.println(str.toString());
1 Comment
Colin Hebert
As it's an assignment I don't think he can bend the rules ;)