Code example for StringTokenizer

Methods: countTokens, nextToken

0
    } 
 
    public Location(String str) {
        this.latitude = 0D;
        this.longitude = 0D;
        StringTokenizer st = new StringTokenizer(str, ",");
        if (st.countTokens() == 2) {
            try { 
                this.latitude = Double.parseDouble(st.nextToken());
                this.longitude = Double.parseDouble(st.nextToken());
            } catch (NumberFormatException ignore) {
            } 
        } 
    } 
 
    public Double getLatitude() {
        return latitude;
    } 
 
    public Double getLongitude() {
        return longitude;