Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:45:50+00:00 2026-05-27T16:45:50+00:00

I want this sentence to out like . What is wrong here because it

  • 0

I want this sentence to out like . What is wrong here because it give me
java.lang.ArrayIndexOutOfBoundsException

package first;

import org.apache.commons.lang.RandomStringUtils;


public class reverseString2 {

public static void main(String []args){



        String str = "The student so lazy";
        String[] split = str.split(" ");
        String middle = null;
        StringBuilder output = new StringBuilder();

        for (String s : split) {
            middle = s.substring(1, s.length()-1 );
            s = s.replace(middle,RandomStringUtils.random(5, middle));
            output.append(s + " ");
        }

        System.out.println(output.toString());
    }



}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:45:51+00:00Added an answer on May 27, 2026 at 4:45 pm

    You need to copy and paste your exact stack trace.

    I wrote my own random method, because I don’t have the the best setup on this machine, and here’s what I got:

    import java.util.*;
    class reverseString2 {
    
    public static void main(String []args){
    
    
    
            String str = "The student so lazy";
            String[] split = str.split(" ");
            String middle = null;
            StringBuilder output = new StringBuilder();
    
            for (String s : split) {
                middle = s.substring(1, s.length()-1 );
                s = s.replace(middle,random(5, middle));
                output.append(s + " ");
            }
    
            System.out.println(output.toString());
        }
    
        static String random(int i, String s) {
            char[] ca = s.toCharArray();
            List<Character> list = new ArrayList<Character>();
            for(char c : ca) list.add(c);
            Collections.shuffle(list);
            StringBuilder sb = new StringBuilder();
            for(Character ch : list) sb.append(ch);
            return sb.toString();
        }
    
    }
    

    result:

    # 1:   hide   clone   input   2 seconds ago
    result: success      time: 0.09s    memory: 212416 kB     returned value: 0
    
    input: no
    output:
    The suntedt so lzay 
    

    Link http://ideone.com/5flnU

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NSUInteger wordInt = sentence.length; I want to add 1 like this -> wordInt =
Here's a simple (hopefully) L10N question: Do all locales want this format: Sunday, Nov
Example: This is just\na simple sentence . I want to match every character between
I have a sentence like 'This is [[a captured group]].' The number of words
I want to pull out capitalized words that don't start a sentence along with
I want this url http://www.youtube.com/watch?v=dgNgODPIO0w&feature=rec-HM-fresh+div to be transformed to: http://www.youtube.com/v/dgNgODPIO0w with php.
I want this: http://jqueryui.com/demos/dialog/#modal-message to happend when you click on ClickMe. how to do
I want this for some conditional compilation code that will run in all IE's
I want this to be on top... how can I do this and not
I only want this function to run if .toolbar li does not have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.