read names in stringList

delphi tstringlist
delphi tstrings
delphi tstringlist indexof
delphi tstringlist values

I wanted to print a list of names from the arrayList:

public class arrReader {
static Scanner input = new Scanner(System.in);
static ArrayList<String> arr = new ArrayList<String>();

public static void main(String[] args) {
    System.out.println("Please enter your names: ");
    String names = input.next();
    while(names.length()>0) {
        arr.add(names);
        names = input.nextLine();
    }

    PrintArry();
}


public static void PrintArry() {
    System.out.println("------------------------------------");
    for (String i : arr) {
        System.out.println(i);

    }
}

}

the result is: Please enter your names: Apple Banana Peace


Apple

Banana Peace

how do I get the name display in one line? Also why do I have to enter twice to get the result? thanks!


Could you try:

System.out.print(i);

instead of:

System.out.println(i);

The method println prints i and afstand a new line

Get id from Values in a StringList, Example is from the Delphi Basics, but TStringList.Names is also described in the Delphi documentation // Now display all name and age pair  This C# example page uses a string List, with the generic type syntax. It loops over a string list and uses a string List argument. Consider all the names in the world. There are many. We might want to store some of them in a collection, packed together—in a string List. List. With a string List, each element is added with a method like Add


To NOT add "," after last one.

if (arr.size() > 0) {
    System.out.print(arr.get(0));
    for (int i = 1; i < arr.size(); i++) {
        System.out.print(", " + arr.get(i);
    }
}

TStrings.Names Property, When the list of strings for the TStrings object includes strings that are name-​value pairs, read Names to access the name part of a string. Names is the name​  Name Description; StringList() Initializes a new instance of this StringList class. StringList(IEnumerable<String>) Initializes a new instance of the StringList class with the specified enumerable collection of strings. StringList(String) Initializes a new instance of the StringList class with the specified comma-separated list.


Or if you use JAVA 8, you can try with this:

public static void PrintArry() {
    System.out.println("------------------------------------");
    Arrays.stream(arr).forEach(System.out::print);
}

TStringList Members, DefineProperties. Reads and writes the Strings property as if it were published. ExtractName. Returns the name portion of a string that is a name value pair. CODE {Target is the string to be matched with a name; TempList is the StringList of Name-Value pairs to be searched; Position is the position in TempList returned by IndexOfName; OutLine is the value part of a match; ProcessOutLine is a separate procedure which processes Outline.} Position :=


TStringlist Name Value pair, Store list of Values assigned to Names in a string list like 1,2,3,4,5 Returns Index of Name stored in TStringlist when using name/value pairs. In this blog I will describe how to read and write data from and to an Excel file. names : TStringList; // Define our string list variable ageStr : String; i : Integer; begin // Define a string list object, and point our variable at it names := TStringList.Create; // Now add some names to our list names.CommaText := 'Neil=45, Brian=63, Jim=22'; // And now find Brian's age ageStr := names.Values['Brian'];


TStrings.Values, When reading this property, if there is a name-value pair in the list of strings that has name part Name , then the corresponding value is returned. If there is no such  This is InsertItem, a member of class TStringList. Changes the value of the string with a specified index. Changes the object associated with the string at a specified index. Changes the amount of memory allocated to hold strings in the list.


Loading the name-value pairs from file in TStringList, What I am actually trying to do, is to read those couples nameX=valueX in a TStringList and then load them in a TComboBox, so that the  But TStringlist provides a distinct feature that allows to store Name and Value pair as a list item at a same time like 'James=1' in which James=Name and 1=Value. And some TStringlist properties or methods used for Name and Value pair are