Java Random String generateRandomSentence()

Here you can find the source of generateRandomSentence()

Description

generate Random Sentence

License

Apache License

Declaration

public static String[] generateRandomSentence() 

Method Source Code

//package com.java2s;
/*/*from  w w w.ja v  a 2 s .com*/
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.util.Random;

public class Main {
    private static Random r = new Random();

    public static String[] generateRandomSentence() {
        int dimension = r.nextInt(10);
        String[] sentence = new String[dimension];
        for (int j = 0; j < dimension; j++) {
            char c = (char) r.nextInt(10);
            sentence[j] = c + "-" + c + "-" + c;
        }
        return sentence;
    }
}

Related

  1. generateRandom(int num)
  2. generateRandom(Integer digits)
  3. generateRandomChain(int length)
  4. generateRandomCharacters(int N)
  5. generateRandomCode()
  6. generateRandomStr(final int length)
  7. generateRandomStr(int length)
  8. generateRandomString()
  9. generateRandomString()