public static string getstring(throws ioexception inputstreamreader isr new inputstreamreader(system in)bufferedreader br new bufferedreader(isr)string br readline()return sthis method returns string objectwhich is composed of characters typed on the keyboard and terminated with the enter key besides importing java io *you'll also need to add throws ioexception to all input methodsas shown in the preceding code the details of the inputstreamreader and bufferedreader classes need not concern us here this approach was introduced with version of sun microsystemsjava development kit (jdkearlier versions of the jdk used the system in object to read individual characterswhich were then concatenated to form string object the termination of the input was signaled by newline ('\ 'charactergenerated when the user pressed enter here' the code for this older approachpublic string getstring(throws ioexception string ""int chwhile(ch=system in read()!- &(char)ch !'\ns +(char)chreturn shere characters are read as integerswhich allows the negative value - to signal an end-of-file (eofthe while loop reads characters until an end-of-file or newline occurs you'll need to use this version of getstring(if you're using older versions of the jdk inputting character suppose you want your program' user to enter character (by enter we mean typing something and pressing the enter key the user may enter single character or (incorrectlymore than one thereforethe safest way to read character involves reading string and picking off its first character with the charat(methodpublic static char getchar(throws ioexception string getstring()return charat( )the charat(method of the string class returns character at the specified position in the string objecthere we get the first one the approach shown avoids extraneous