Im tryingto make a msg command. How would I get the last args in what the user said like from args[3]+
Code: StringBuilder sb = new StringBuilder(); for (int i = 3; i < args.length; i++){ sb.append(args[i]); if (i<args.length) sb.append(" "); } System.out.println(sb.toString());
I may be mistaken but don't arrays have a length function/variable? So iteratively add each argument into a string, starting at 3 and ending at array.length. Edit: what this guy said^ Well, a StringBuilder class seems a bit excessive. But yeah.
If you want to retain it in array format, you can use the subarray commands but the method i showed makes it into a message.