What's new

Java Help po

Handnasomepa

Forum Guru
Elite
Joined
Dec 31, 2018
Posts
2,269
Solutions
20
Reaction
9,868
Points
1,799
hello patulong sa coding kahapon ko pa to pinoproblema di ko talaga magawan ng paraan


Suppose may array ka:
Array A contains elements:
(index 0) Cash on hand, Accrued Depreciation, Land
(index 1) Vehicles, Accounts Payable
(index 2) Capital, wí†hdráwal, Notes Payable

Automatically ang length syempre ng array ay kung ilan ang laman na elements

Ang objective dito ay maiseparate nya yung mga account titles sa isa't isa so for example sa array natin. Ang dapat na kalabasan ay:
(index 0) Cash on hand
(index 1) Accrued Depreciation
(index 2) Land
(index 3) Vehicles
(index 4) Accounts Payable
(index 5) Capital
(index 6) wí†hdráwal
(index 7) Notes Payable

So kung makikita niyo naseparate yung mga word/s per comma. Help po
 
Split ang gusto mong mangyayari paps, ito ang sample code.

String animals = "dog, cat, bird, fish, snakes";

String[] animalsArray = animals.split(",");
 
String[] a ={"Accrued", "Depreciation" ,"Land" , "Vehicles" , "Accounts Payable" , "Capital" , "wí†hdráwal" , "Notes Payable"}

for(i = 0; i <= a.length(); i + +) {
System.out.println(a) ;
 
Concatenate mo po yung lahat ng strings then do the split.
Ang gusto ko po kasi mangyari paps

lets say:

String animals1 = "dog, cat, bird";
String animals2 = "fish, snakes";
String animals3 = "turtle, goat, sheep, cow, lion";
and so on..

Gusto ko po sa iisang array
may laman siya na::
dog
cat
bird
fish
snakes
turtle
goat
sheep
cow
lion

Nagegets nyo po ako?
 
Ang gusto ko po kasi mangyari paps

lets say:

String animals1 = "dog, cat, bird";
String animals2 = "fish, snakes";
String animals3 = "turtle, goat, sheep, cow, lion";
and so on..

Gusto ko po sa iisang array
may laman siya na::
dog
cat
bird
fish
snakes
turtle
goat
sheep
cow
lion

Nagegets nyo po ako?
yes, concatenate(pagsamasamahin mo lahat ng string sa array) then tsaka mo i-split

Sample:
Java:
public class Main{
    public static void main(String[] args) {
        String[] array = {"1, 2, 3", "4, 5, 6", "7, 8, 9"};
        String concatenatedArray = array[0] + ", " + array[1] + ", " + array[2];
        String[] splitted = concatenatedArray.split(",");
    }
}
 
yes, concatenate(pagsamasamahin mo lahat ng string sa array) then tsaka mo i-split

Sample:
Java:
public class Main{
    public static void main(String[] args) {
        String[] array = {"1, 2, 3", "4, 5, 6", "7, 8, 9"};
        String concatenatedArray = array[0] + ", " + array[1] + ", " + array[2];
        String[] splitted = concatenatedArray.split(",");
    }
}
Salamat po paps! Laking tulong ☺️
 
Back
Top