Question about IBM ThinkPad T41 Notebook

1 Answer

Java how to accept a string value in java

Posted by on

  • Gitanjali Jun 10, 2008

    how to accept a string value in java

  • Gitanjali Jun 10, 2008

    how to accept a string value in java


1 Answer

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points


    An expert that got 10 achievements.


    An expert that got 5 achievements.


    An expert who has answered 1,000 questions.

  • Master
  • 2,028 Answers

You wil get a better reponse if you pay for the expertise we have to offer!

Posted on Jun 24, 2008

1 Suggested Answer

  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%


Complete. Click "Add" to insert your video. Add



Related Questions:

1 Answer

How can I format a java string using a width variable?

The Entities in java are slightly different. I adore them being included (finally).

float bigNum = 123456.789012;

String pattern = String.format( "%10.2f is my magic number%n", bigNum);

System.out.println( pattern);



String.format( "%10.3f", bigNum) );

the "decimal place" is the rounding.

lead off with a zero to get leading zeroes

String.format("%03.2f", bigNum));

if I want evenly spaced columns, I have to construct an Object[] array

array[0] = salaryAmt;

array[1] = hourly Rate;

array[2] = "Cowboy Bob";


"%5.2f,%3.2d,%s%n, array);

Here you will get more information about java string format.

Nov 21, 2012 | Jeep Cars & Trucks

2 Answers

What is strings in java?

Handling character strings in Java is supported through two final
classes: Java String and StringBuffer. The String class implements immutable character strings, which are read-only once the string has been created and initialized, whereas the StringBuffer class implements dynamic character strings. All string literals in Java programs, are implemented as instances of String class. Strings in Java are 16-bit Unicode.

Nov 21, 2012 | Sun Java Programming Language (cdj-275)

1 Answer

I installed Printmaster 2011 platinum on my pc. Everything went well until I tried to print my project. I have an error message everytime that says: Printmaster 2011 Platinum 3.0.70 encountered the...

PrintMaster 2011 Platinum encountered the following error:

java.lang.NumberFormatException: For input string: "12,00"
at sun.misc.FloatingDecimal.readJavaFormatString(
at java.lang.Float.valueOf(
at com.storyrock.dlog.PrintWizardDialog.a(SourceFile:1982)
at com.storyrock.dlog.PrintWizardDialog.(SourceFile:386)
at com.storyrock.ui.actions.PrintAction.doAction(SourceFile:103)
at com.storyrock.ui.actions.ApplicationAction$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

If this situation persists, please visit the technical support website at

Oct 22, 2010 | Broderbund PrintMaster Platinum

1 Answer

How to convert infix to postfix using stacks in java programming?

u can try the follwing coding
import java.util.*;
//begin coding for the stack interface
interface Stack<E>
public boolean isEmpty();//tests is current stack is empty. Returns true if so, and false if not.
public E top() throws StackException;//retrieves value at the top of the stack. Stack cannot be empty.
public void push(E value) throws StackException;//pushes a value on the top of the stack.
public void pop() throws StackException;//removes a value from the top of the stack. Stack cannot be empty.
}//terminates coding of Stack interface

//begin coding for the objArrayStack class
class objArrayStack<E> implements Stack<E>
public objArrayStack()
}//terminates constructor
public void push(E value)throws StackException
if(topValue<ArraySize-1)//currrent stack is not full
}//terminates if
else //current stack is full
throw new StackException("Error: Overflow");
}//terminates push method
public void pop() throws StackException
if(!isEmpty())//current stack is not empty
else //stack is empty
throw new StackException("Error: Underflow");
}//terminates pop method
public boolean isEmpty()
return topValue==-1;
}//terminates isEmpty method
public E top() throws StackException
if(!isEmpty())//stack is not empty
return (E)Info[topValue];
else //stack is empty
throw new StackException("Error: Underflow");
}//terminates top method
//declare instance variables
final int ArraySize=10;
private Object Info[]=new Object[ArraySize];
private int topValue;

//begins coding for the StackException class
class StackException extends RuntimeException
public StackException(String str)
}//terminates text of constructor
}//terminates text of StackException class

//method to convert from infix to postfix notation
public static String InToPost(String infixString)
//operator stack initialized
objArrayStack<Character> operatorStack = new objArrayStack<Character>();
//postfix string initialized as empty
String postfixString = " ";
//scan infix string and take appropriate action
for(int index = 0; index < infixString.length(); ++index)
char chValue = infixString.charAt(index);
if(chValue == '(')
else if(chValue == ')')
Character oper =;
while(!(oper.equals('(')) && !(operatorStack.isEmpty()))
postfixString += oper.charValue();
oper =;
}//end while loop
}//end else if
else if(chValue == '+' || chValue == '-')
if(operatorStack.isEmpty()) //operatorStack is empty
else //current operatorStack is not empty
Character oper =;
while(!(operatorStack.isEmpty() || oper.equals(new Character('(')) || oper.equals(new Character(')'))))
postfixString += oper.charValue();
}//ends while loop
}//end else
}//end else if
else if(chValue == '*' || chValue == '/')
Character oper =;
while(!oper.equals(new Character('+')) && !oper.equals(new Character('-')) && !operatorStack.isEmpty())
postfixString += oper.charValue();
}//end while loop
}//end else
}//end else if
postfixString += chValue;
}//end for loop
Character oper =;
if(!oper.equals(new Character('(')))
postfixString += oper.charValue();
}//end if
}//end while
return postfixString ;
}//terminates text of InToPost method

public static void main(String[]args)
objArrayStack mystack = new objArrayStack();
System.out.println("Enter a string");
Scanner scan = new Scanner(;
String str = scan.nextLine();
}//terminates text of main method
}//terminates text of objArrayStack class

Mar 16, 2010 | Sun Java Programming Language (cdj-275)

1 Answer

I want to read text file which is located in c drive using java code can anybody help me out

import java.util.Scanner;

public final class ReadWithScanner { public static void main(String... aArgs) throws FileNotFoundException {
ReadWithScanner parser = new ReadWithScanner("C:\\Temp\\test.txt");

* @param aFileName full name of an existing, readable file.

public ReadWithScanner(String aFileName){
fFile = new File(aFileName);

/** Template method that calls {@link #processLine(String)}. */
public final void processLineByLine() throws FileNotFoundException {
Scanner scanner = new Scanner(fFile);
try {
//first use a Scanner to get each line
while ( scanner.hasNextLine() ){
processLine( scanner.nextLine() );
finally {
//ensure the underlying stream is always closed

* Overridable method for processing lines in different ways.
* <P>This simple default implementation expects simple name-value pairs, separated by an
* '=' sign. Examples of valid input :
* <tt>height = 167cm</tt>
* <tt>mass = 65kg</tt>
* <tt>disposition = "grumpy"</tt>
* <tt>this is the name = this is the value</tt>

protected void processLine(String aLine){
//use a second Scanner to parse the content of each line
Scanner scanner = new Scanner(aLine);
if ( scanner.hasNext() ){
String name =;
String value =;
log("Name is : " + quote(name.trim()) + ", and Value is : " + quote(value.trim()) );
else {
log("Empty or invalid line. Unable to process.");
//(no need for finally here, since String is source)

private final File fFile;

private static void log(Object aObject){

private String quote(String aText){
String QUOTE = "'";
return QUOTE + aText + QUOTE;

Jun 22, 2009 | Sun Java Programming Language (cdj-275)

1 Answer

Code for method parseInt() in java

parseInt(java.lang.String, int)

This code takes two arguments, a string constructor from the Java language and an integer. Its purpose is to parse (meaning de-construct or disassemble into component parts) one data type into another.

Here is an example of a Java program to specify and print out the dimensions of a rectangle, taken from the page

class Rectangle{
int length, breadth;
void show(int x, int y){
length = x;
breadth = y;
int calculate(){
return(length * breadth);
public class EnterValuesFromKeyboard{
public static void main(String[] args) {
Rectangle rectangle = new Rectangle();
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);, b);
System.out.println(" you have entered these values : " + a + " and " + b);
int area = rectangle.calculate();
System.out.println(" area of a rectange is : " + area);

Apr 09, 2009 | Sun Java Programming Language (cdj-275)

2 Answers

Rename a folder in c drive using java code


public class RenameFileOrDir{

public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(;
System.out.print("Please enter the file or directory
name which has to be Renamed : ");

String old_name = in.readLine();
File oldfile = new File(old_name);


System.out.println("File or directory does not exist.");



System.out.print("please enter the new file or directory name : ");

String new_name = in.readLine();

File newfile = new File(new_name);

System.out.println("Old File or directory name : "+ oldfile);
System.out.println("New File or directory name : "+ newfile);
boolean Rename = oldfile.renameTo(newfile);


System.out.println("File or directory does not rename successfully.");



else {

System.out.println("File or directory rename is successfully.");




Mar 30, 2009 | Sun Java Programming Language (cdj-275)

1 Answer

Please explain the working of this code

It's a Java http server (webserver) that serves random "prices" if they match a search string.

Well here is an explaination:

private static String[] symbols = {"DELL", "INTC", "MSFT", "ORCL", "SUNW"};
These are search strings

private static Random rnd = new Random();
This generates a random number

private static Charset cs = Charset.forName("UTF-8");
This is the charset that the http server uses

ServerSocketChannel server =;
Create a new server

server.socket().bind(new InetSocketAddress(8055));
Bind the http server to port 8055

The rest is handling the request and processing it

But here:
if(Arrays.binarySearch(symbols, symbol) >= 0)
response = "Price is " + (1000 + rnd.nextInt(9000)) / 100.0;
response = "Price not available";
channel.write(cs.encode("HTTP/1.0 200 OK "));
channel.write(cs.encode("Content-type: text/plain "));
It sees if the string input matchs: DELL INTC MSFT ORCL SUNW.

(private static String[] symbols = {"DELL", "INTC", "MSFT", "ORCL", "SUNW"};)
If so, it gives a price based on a random number.
response = "Price is " + (1000 + rnd.nextInt(9000)) / 100.0;)
Or else
It says "price not available"
then it gives a html header to end the error message.

Hope I helped you :)
Gook luck

Nov 26, 2008 | Computers & Internet

3 Answers

Jawa void

you should not use arguments in void function in java ... in java pertaining to void the compiler doesn't understand the arguments and treats that as invalid... in c it is ok

Aug 07, 2008 | Sun Java Studio Standard 5 (SSJI9501TL9M)...

Not finding what you are looking for?
IBM ThinkPad T41 Notebook Logo

Related Topics:

29 people viewed this question

Ask a Question

Usually answered in minutes!

Top IBM Computers & Internet Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18386 Answers

Computer Links

Level 3 Expert

2385 Answers

Michael Vincent Cruz

Level 3 Expert

868 Answers

Are you an IBM Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides