tow method to read and write .

tow method to read and write .

i have two method , frist named "readString" which has no input ,and output b type string ,. second method named "writeString" which accept b as imput and return nothing .........please i want solution this program ....help me please

View Answers

December 20, 2010 at 1:12 PM

Hi Friend,

Try the following code:

import java.util.*;
class  Methods
{
    public String readString(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter String: ");
        String st=input.nextLine();
        return st;
    }
    public void writeString(String st){
        System.out.println("You have entered: "+st);
    }
    public static void main(String[] args) 
    {
        Methods m=new Methods();
        String str=m.readString();
        m.writeString(str);
    }
}

Thanks


August 1, 2011 at 7:50 PM

import java.util.Scanner; public class test { public static void main(String[]args) { Scanner scan=new Scanner(System.in); System.out.println("1st digit..."); int x=scan.nextInt(); System.out.println("1st digit..."); int y=scan.nextInt(); int z=x+y; System.out.println("Sum="+z); } }









Related Tutorials/Questions & Answers:
tow method to read and write .
tow method to read and write .  i have two method , frist named "readString" which has no input ,and output b type string ,. second method named "writeString" which accept b as imput and return nothing .........please i want
Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory
Advertisements
Read and write file
Read and write file  HI, How to read and write file from Java program? Thanks   Hi, See the following tutorials: Java Write To File Read File Thanks
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
ModuleNotFoundError: No module named 'write-read'
ModuleNotFoundError: No module named 'write-read'  Hi, My Python... 'write-read' How to remove the ModuleNotFoundError: No module named 'write-read' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'write-read'
ModuleNotFoundError: No module named 'write-read'  Hi, My Python... 'write-read' How to remove the ModuleNotFoundError: No module named 'write-read' error? Thanks   Hi, In your python environment you
how to write and read text for javaME
how to write and read text for javaME  Hi. I have tried ur read/write coding but why i didnt get the o/p just like urs. do i have to add anything from the library? i want to type multiple line on text file then, read it from
Java file read write operation
Java file read write operation  how to read and write the data from text file.Suppose i have text file with 4 fields name ,roll no ,marks1,marks2 with more than 20 records......i need to store these value in object and pass
How to write method for UITableView didSelectRowAtIndexPath?
How to write method for UITableView didSelectRowAtIndexPath?  Hi, Please tell me how to write method for UITableView didSelectRowAtIndexPath? Thanks   HI, Here is the code: -(void)tableView:(UITableView *)tableView
read/write to Windows Registry using Java
read/write to Windows Registry using Java  read/write to Windows Registry using Java
write a progam for bubble sort using file read nd write?
write a progam for bubble sort using file read nd write?  hi, please give the code
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
how to read and write xml files in javascript
how to read and write xml files in javascript  hi m very new to javascript and xml,, now i want to read and write xml files in javascript,, please give me a sample code to do
To read & write a excel file using the core java
To read & write a excel file using the core java  Hai, I'm new to JavaProgram.But now i need java program to read & write a excel file so, can anyone help me to learn the above mentioned topic(link for the portion
J2ME RMS Read Write
J2ME RMS Read Write       This Application specially tries to explain how to read and write the data using RecordStore class. In the RecordStore class the following methods
How i write a function/method in jsp?
How i write a function/method in jsp?  How write the function/method in jsp? Using that method i can retrieve the value coming from database. give me example plz. Actually i want to show the list of user detail
can we write a method in JSP - JSP-Servlet
can we write a method in JSP  Hi All, In my web application I want... a class's method() from jsp and I can come back to the next instruction of jsp... write you requirement clear then i can able to give ans. thanks rajkumar
ModuleNotFoundError: No module named 'tow'
ModuleNotFoundError: No module named 'tow'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tow' How to remove the ModuleNotFoundError: No module named 'tow' error
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?  write a program in java to read a text file and write the output to an excel file using filereader and filewriter
Use of write method of CheckedOutputStream class in java.
Use of write method of CheckedOutputStream class in java. In this tutorial, we will discuss the use of write(int b) method of CheckedOutputStream class... and calculate checksum value. The write(int b) method is used to write a bytes
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
Write a C language program to read two matrices and multiply them?
Write a C language program to read two matrices and multiply them?  Write a C language program to read two matrices and multiply them?   ...;stdio.h> #include <conio.h> int main() { int m, n, p, q, c, d, k, sum
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...) { //read from start original file String arry[] = sCurrentLine.split...); String delimeter=","; System.out.println("call prepareGroupBy method
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...) { //read from start original file String arry[] = sCurrentLine.split...); String delimeter=","; System.out.println("call prepareGroupBy method
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...) { //read from start original file String arry[] = sCurrentLine.split...); String delimeter=","; System.out.println("call prepareGroupBy method
Java program to read a text file and write to another file
Java program to read a text file and write to another file - Creating.... Our requirement is to read a text file and then write the content of the text... the data we have use the read() method of FileInputStream class. Here
add tow numbers with out using arthamatic operaters
add tow numbers with out using arthamatic operaters  add tow numbers with out using arthamatic operaters
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data... column value that keeps on changing for every file.i have read the data from all the files and write them into a single file..the target file should have the 1st
write a program to calculate volume of a cube, cylinder, rectangular box using method overloading
write a program to calculate volume of a cube  write a program to calculate volume of a cube, cylinder, rectangular box using method overloading  
Display tow dimensional array using one for loop in java
Display tow dimensional array using one for loop in java  Display tow dimensional array using one for loop in java
method
method  can you tell me how to write an abstract method called ucapan() for B2 class class A2{ void hello(){ system.out.println("hello from A2"); }} class B2 extends A2{ void hello(){ system.out.println("hello from B2
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java
Write to a file
Write to a file       As we have read about  the BufferedOutputStream class that store the data in an internal buffer and lets you write
recursive method
recursive method  Write a recursive method to add the first n terms of the series 1 + (1/2) - (1/3) + (1/4) - (1/5
How to Read file line by line in Java program
Reader and readline() method one can read the data faster even on the computer... have used the readLine() method of BufferedReader class that is used to read..._TO_REPLACE_3 read() method of BufferedReader class that reads a character from
write java prgram
write java prgram  write java program to offer a menu which contains 3 choices to make calculation on 3 shapes.use method for each calculation
write spreadsheet
write spreadsheet  what is the java code to write a spreadsheet to database
write spreadsheet
write spreadsheet  what is the java code to write a spreadsheet to database
How to read properties file in Python using configparser?
How to read properties file in Python using configparser and printing the property value? In Python we can read the configuration file and then is required.... In this tutorial we are going to make a sample property file and then read
write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
Write a MoveFirst() for Circular Linked List
Write a MoveFirst() for Circular Linked List  write a MoveFirst(T elt) method to point the head at that element. Then the tail would point...); it should read "two three four one
Class and method question, Java?
({}); a. Write preconditions and postconditions for the method getValue b...Class and method question, Java?  Consider a Java class that you... Prompt string** and the following method: getValue displays the prompt and reads
Ajax Write
Ajax Write       ajaxWrite is a web-based word processor that can read and write Microsoft Word and other standard document formats Read full Description ADS_TO_REPLACE_1
method over riding
method over riding  write a java program to compute volume of sphere and volume of cylinder using method over riding
WRITE AND TEST
WRITE AND TEST   WRITE AND TEST PROGRAM TO ACCEPT A STRING? 1).WHICH STARTS WITH 'S' OR 's' 2).ENDS WITH "nd" 3) THE LENGTH OF THE STRING SHOULD BE 10 OR LESS
Use of Image I/O library
. The ImageIO class provides the method to read and write image. We are providing you... image4.jpg is defined as input file which is read by the method read... ConvolveOp performs a translation on BufferedImages. The method write(output
Write String in Word document
Write String in Word document  How to read and write strings in word document
method inside the method??
method inside the method??  can't we declare a method inside a method in java?? for eg: public class One { public static void main(String[] args) { One obj=new One(); One.add(); private static void add

Ads