Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning Java 2
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 18th, 2006, 08:31 AM
Registered User
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to print a string value in a single line

Hi, can anyone please help me to print the string value "bbb" in the method "printing" as a single string value instead of two string values. My code is:

private void jComboBox4ActionPerformed(java.awt.event.ActionEve nt evt)
    String b=null;
    String bb=null;
    Object a=jComboBox4.getSelectedItem();
    printing(bb); //passing "bb" to the method "printing"

private void jComboBox5ActionPerformed(java.awt.event.ActionEve nt evt)
    String b=null;
    String bb=null;
    Object a=jComboBox5.getSelectedItem();
    printing(bb); //passing "bb" to the method "printing"

private void printing(String bbb)
    System.out.println("bbb: "+bbb);

My output is:
bbb: 0
bbb: n

But need my output as:
bbb: 0n

Old February 13th, 2007, 06:36 AM
Friend of Wrox
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts

Well yeh, it will do it like that because that's how you've structured your program ;)

If you need it to do:

bbb: OnnnOnO... etc.

Then print the "bbb: " in your constructor and replace your System.out.println with System.out.print.

Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk

Similar Threads
Thread Thread Starter Forum Replies Last Post
store a single line of text from a file....how???? danielnixon General .NET 2 May 1st, 2008 12:09 PM
Section Line Not to Print bharatsaboo Crystal Reports 2 November 4th, 2007 11:45 AM
Reading a string from line by line vaidyapragati ASP.NET 2.0 Professional 1 May 3rd, 2007 08:43 AM
how to return string value with quotes (single or tllcll BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 November 10th, 2005 01:57 PM
html table data single line -- Solved rupen HTML Code Clinic 1 August 8th, 2005 02:26 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.