| Author |
Concatenating two String arrays
|
Mary Anu
Greenhorn
Joined: May 01, 2004
Posts: 10
|
|
Hi, I have two string arrays, say, String a[] and String b[]. I want to concatenate these two string arrays into a single one, ie by appending all the elements of b after that of a. Is there any simpler method for doing the same other than putting it in a loop? thanks anu.
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
Seems there is currently (J2SE 1.4) no other means to do that in a one-call method. Nick
|
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
Example Output
4 [1, 2, 3, 4] [1, 2, 3, 4]
This solution will help you. [ August 24, 2004: Message edited by: somkiat puisungnoen ]
|
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Last 2 lines of somkiat work only for java 5. somkiat, where are you from?
|
Groovy
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
Hi Pradeep Bhat , I come from THAILAND ..... Land of smile ...
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Pradeep Bhat: somkiat, where are you from?
He is from Thailand as well... But he's native is Thai, while I am not... We used to be in a team before, since we both are outsourcing employees of different companies... For more info, you might query him by your self...
|
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Ko Ko Naing: He is from Thailand as well... But he's native is Thai, while I am not...  We used to be in a team before, since we both are outsourcing employees of different companies... For more info, you might query him by your self...
Great !
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
wow... you 2 guys know already? Nick
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Nicholas Cheung: wow... you 2 guys know already? Nick
Both win lot of books also.
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Nicholas Cheung: Seems there is currently (J2SE 1.4) no other means to do that in a one-call method. Nick
For one-call method of somkiat's code, here we go... Put it in a class and use it as we need....
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Nicholas Cheung: wow... you 2 guys know already? Nick
Well, but we lost contact each other for long already... One of the reasons is that I use English as my main language here in Thailand, while he use Thai language as his main language... But I do speack Thai quite well... People with different main language are difficult to communicate with each other, I feel...
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Pradeep Bhat: Both win lot of books also.
Reasons to join the book promotions for people out here from Thailand might be as the following: 1. Programmers' average salary are relatively low compared to the programmers in other developed countries like Nick from Hong Kong, Pradeep from India 2. Newly published books are difficult to find in local bookstores, unless we try to order them online via Amazon, for example, paying the higher price than the books available in the local bookstores But there may be more personal reasons in participating in a book promotion... For example, somkiat and me might have different personal reasons, since we both were born in different countries and speak different mother language... Hope this helps...
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
But he can now communicate with us using english. Nick
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
Originally posted by Nicholas Cheung: But he can now communicate with us using english. Nick
Oh yes, i can use BUT I know it not good .... :roll: :roll:
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Nicholas Cheung: But he can now communicate with us using english. Nick
Originally posted by somkiat puisungnoen: Oh yes, i can use BUT I know it not good ....  :roll: :roll:
Yes he can... But you might notice some grammatical mistakes in his posts... It's not a big deal, while we are talking in the same language, which is Java... Isn't Java a kind of language? I have learnt in "Theory of Computation" course that programming lannguage is a subset of natural langauge, so are context-free, context-sensitive and regular language... Off-topic, BTW..
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
1. Programmers' average salary are relatively low compared to the programmers in other developed countries like Nick from Hong Kong, Pradeep from India
India is not developed . Salary is 1/10 of US.
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
For Thailand, I guess it would be about 1/12 or less... Anyway, I belive India's average salary for programmers higher than that of Thailand for sure...
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
IT in HK will soon or later *game over*. China is going to pick up more and more IT related tasks. Nick
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Nicholas Cheung: IT in HK will soon or later *game over*. China is going to pick up more and more IT related tasks.
Then should I postpone my plan to settle in HK? And consider about the China?
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
Ko Ko, Thus, we may some day meet in China. Nick
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Nicholas Cheung: Ko Ko, Thus, we may some day meet in China. Nick
Probably! But I still do prefer HK than Shiang Hai...
|
 |
 |
|
|
subject: Concatenating two String arrays
|
|
|