Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i want to make it where i can get the string (2,p1, and 32) from the sentence at 2 add p1 32 1 import java.util.Scanner;

i want to make it where i can get the string (2,p1, and 32) from the sentence "at 2 add p1 32"

image text in transcribed

1 import java.util.Scanner; 2 3 public class call { 4 5 public static void main(String[] args) { 6 Scanner in = new Scanner(System.in); // at 2 add p1 32 8 //01 23 456 7 89 10 11 12 9 String n = in.next(); 10 System.out.println(n); 11 String w = n.substring(3); 12 System.out.println(); 13 14 15 } 16 17 } 18 A Problems @ Javadoc Declaration Console X call [Java Application] C:\Program Files Vava\jre 1.8.0_221\bin\javaw.exe (Jan 30, 2021, 3:49:40 PM) at 2 add at Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) at call.main(call.java:11)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

2. How will the team select a leader?

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago