• Post Reply Bookmark Topic Watch Topic
  • New Topic

Concatenating two String arrays  RSS feed

 
Mary Anu
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems there is currently (J2SE 1.4) no other means to do that in a one-call method.

Nick
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example



Output


4
[1, 2, 3, 4]
[1, 2, 3, 4]


This solution will help you.
[ August 24, 2004: Message edited by: somkiat puisungnoen ]
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Last 2 lines of somkiat work only for java 5.
somkiat, where are you from?
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradeep Bhat ,


I come from THAILAND ..... Land of smile ...
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow... you 2 guys know already?

Nick
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Cheung:
wow... you 2 guys know already?

Nick


Both win lot of books also.

 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But he can now communicate with us using english.

Nick
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:


India is not developed .
Salary is 1/10 of US.


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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ko Ko,

Thus, we may some day meet in China.

Nick
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!