Printing on chars on the same line using system.out.println

i have the following string:
String msg = "This is a message brought to you by one and the only";
msg.toCharArray(); //converted to a char array.
i've written a loop which goes through each of the char elements
and puts it in it's own array:
int i = 0;             
while (i < msg.length)
                char[] test = {msg};
System.out.println(test);
the problem is system out println prints out each of the elements on seperate lines is
it possible to have them in one line to reform the original string?

No exactly sure what you are trying to do. Does this
help?
String msg = "This is a message brought to you by one
and the only";
char[] test = msg.toCharArray();
System.out.println(test);
not really because i want to convert the string to a char array and then reform it in another char array and then i can choose which elements i want included and not to be so that it can be printed on the same line. I can do it the following way:
char[] test = {test[0], test[1]]};
but say i want all the letters containing the chracter T (and again i can use the above solution and select the elements from the string but i don't want to hardcode it, say the string changes etc) in the test array so then i thought of writing a loop:
while (test[i] == 'T')
char[] test2 = {test[i]};
System.out.println(test);
i++;
but it puts each T in a new line...

Similar Messages

  • Multiple Threads Using System.out.println...

    i have a client server app and each client that connects to the server has its own thread.
    i am running the server on a pc using windows xp and to run it i just use a bat file which uses cmd.exe and my output using System.out.println prints out in the cmd.exe.
    each of my threads is using System.out.println to send debug info and outs quite often.
    after the screen fills a scroll bar appears at the right and you can scroll back to see past output.
    my app is all running ok but when i had a ton of output coming in all at once i tried to scroll back to see the older output and realized that if i click down on the scroll bar and fight the new input it freezes my server app. then when i release it it continues lol.
    it made me wonder if output from multiple threads when there are many all at once (say 20 or 30 threads all outputing at the exact same time) could cause a slow down or effect the performance of the server?
    i use a debug variable so i can just turn this output 100 % off except for critical errors so there would be no output but i am just curious as to whether or not it may be causing problems when its on.

    That's not a performance issue, I guess System.out.println() simply gets blocked by the console while you're scrolling and thus your app stalls, until you stop doing that.
    Maybe you should look into logging.

  • Is it possible not to use System.out.println?

    Hi guyz,
    Can anyone tell me if there is a way not to use System.out.println but produce the output on the command prompt? I need to add two numbers which are accepted through the args(command prompt). I have to add them and show them on command prompt without using System.out.println. Can ANYONE HELP?

    Hi guyz,
    Can anyone tell me if there is a way not
    s a way not to use System.out.println but produce the
    output on the command prompt? I need to add two
    numbers which are accepted through the args(command
    prompt). I have to add them and show them on command
    prompt without using System.out.println. Can ANYONE
    HELP?Why can't you use System.out.println? What's the reason?
    Kaj

  • Using System.out.println

    I am migrating to a Sun server using Iplanet 6. I was on a HP-UX 11.0 server using Iplanet 4.2. I am having problems with two things. First, to get debugging information we use System.out.println in our servlets and JSP's. To get the output, we would redirect our start script when starting the server to a file. The trouble is now there is no output when using System.out.println.
    My second problem is request parameters. I do not always appear to get my request parameters in JSP's that use frames. The outer frameset uses request.getQueryString and then passes the query string to the two frames in the frameset. However, I do not appear to be doing that now.

    Instead of using System.out.println, try looking into the ServletContext.log method.
    I hope this helps with your first question.
    -Richard Burton

  • Using System.out.println() in Scrapbook

    I am working through some tutorials on formatting numbers:
    http://docs.oracle.com/javase/tutorial/java/data/numberformat.html
    I am trying to use scrapbook. I can't seem to get the result I am wanting from System.out.println("Hello world")...I get null. To be specific I am trying to inspect:
    int i = 461012;
    System.out.format("The value of i is: %d%n", i)In this case I get:
    java.io.PrintStream@46b372
    Something tells me that System.out.format can't work in a scrapbook. Is there a way without writing a main and running as java?

    It seems that the format method returns the PrintStream (allowing you to chain method calls), and the return value is being printed.
    You would get the output you're looking for, if you use the String.format() method, since that'll return the formatted String.

  • How use system.out.println with a Java Swing Applet?

    Hi guys,
    I was just wondering what can I use to view output on the Java console with a Java Swing Applet?
    At the moment I'm using a JTextArea within the Applet for debugging but I want output to appear in the browser java console but system.out.println doesn't work.
    I'm viewing the Swing Applet on Netscape 4.7 browser.
    Any ideas?

    System.out.println()s work fine! I'm guessing that your problem is that you are looking at the wrong console window!
    You're using the Java Plug-in, right? On Windows, go to your Control Panel and double click "Java Plug-in". You should find a checkbox option to "Show Java Console" - make sure this is checked. Next time you fire up you JApplet, you should see a Java Console window popup.
    Hope this helps!

  • Where does the logging happens for System.out.println

    Hello:
    I'm usingNetWeaver 2004sJava SP9 evaluation version. Added some System.out.println to the ejbs. Would like to know where to look for the logging details in this case.
    Thanks for your help,
    Ravi

    Hi,
      By default, if the setting has been done, then it appears in defaultTrace as mentioned. For configuration of it, refer to this link.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/db315878-0801-0010-928e-98c8283616d3
    Reward points if it helps.
    Regards,
    Vijai

  • Using System.out.println or System.err.println

    Hi All,
    I've a Web Dynpro project which uses a simple java helper class.
    The java class has 'try catch' statements.
    When I'm in 'catch' I want to display an error message on the screen.
    I know that System.err.println writes the message in the defaultTrace.trc log file in the server but as a developer I don't always have access to the server.
    Is there an option to display the error message on the screen with some kind of response object? (I cannot use wdComponentAPI.getMessageManager.reportSuccess in my helper class)
    Thanks,
    Omri

    Hi Omri,
       It's not true that you cannot use the MessageManager in your helper java classes. Here's how you can do it:
    1. Create a java class in the src directory of your project and in the same packeage as your project. I think you have already done this. Let's say the class is called HelperClass.
    2. Declare a public variable of type com.sap.tc.webdynpro.progmodel.api.IWDMessageManager. Call it say, msgManager. The import will be added automatically.
    3. In the wdDoInit() of your WD write something like:
    HelperClass helperObj = new HelperClass();
    helperObj.msgManager  = wdComponentAPI.getMessageManager();
    4. Then when you catch the exception in your helper class, do a simple reportException().
    Regards,
    Satyajit.

  • Using same line in Console/Screen System.out.println()

    Ok next small prob, and then thats it lol,
    Let's say if I want to print something out to the screen...
    And after that print something again on the same line...
    So, sorta like refreshing the line.
    I can't figure it out because System.out.prinln() jumps to the next line.
    Thnkx in advance
    Robert

    public class Switch
        public static void main(String args[])
            try {
                for(;;){
                    System.out.print("Hello   ");
                    System.out.flush();
                    Thread.sleep(2000L);
                    System.out.print("\u0008\u0008\u0008\u0008\u0008\u0008\u0008\u0008");
                    System.out.print("Good Bye");
                    System.out.flush();
                    Thread.sleep(2000L);
                    System.out.print("\u0008\u0008\u0008\u0008\u0008\u0008\u0008\u0008");
            catch(Exception ex) {
                ex.printStackTrace();
    }

  • How can I place multiple choice boxes on the same line instead of in a column?

    I know it is possible to place multiple fields on the same line, using drag and drop.
    But to save space, I would like to have 3 or 4 multiple choice boxes next to each other on one line. 
    Is this possible, and if so, how?
    Thanks
    Peter

    You may click on the "+" button to the right of the first multiple choice box to add more in the same line. When you hover over the button, the tooltip says "insert item beside".

  • How to print to console with out using system.out.print

    Hi All
    Is it possible to print the text to console with our using System.out.println(). i done as follows but i does not worked
    import java.io.*;
    import java.util.*;
    public class myclass
         public static void main(String[] args)
              BufferedWriter br = null;
              try {
                   br = new BufferedWriter(new OutputStreamWriter(System.out));
                   br.write("Myclass123",0,10);
              } catch (Exception io) {
                   io.printStackTrace();
    so it will be appretaible if any body helps me in solving this question

    i am using sysstem.out to specify that out put
    generated should be pumped to console inted of file.
    i mean system.out will lead to the console. thats why
    i used that. as Either I have no idea what you are talking about, or you have no idea what I am talking about when I refer to writing to File "con".
    suystem.in means keyboard.Actually, it means "the system's standard input stream, wherever it may come from".

  • How to replace System.out.println() using templates

    can you give the complete code for my problem which is given below.
    package include;
    public class P
    public static cout(int a)
    System.out.println( a);
    public static cout(int a,int b)
    System.out.println(a + b);
    // like this i need to write to accept parameters from the class. which is importing this package
    for some more examples
    public static cout(int a,String s)
    System.out.printn(a +s);
    and many more type i.e. all types of arrangements of datatypes
    the above is the package called "include" Now Iam Importing the package in the class Hello:
    import include.P;
    public class Hello
    public static void main(String args[])
    int i=10;
    float f=12.23;
    String s="hello";
    P.cout(i,f); //cout is the static method of package(include) class " P"
    P.cout("welcome",s)
    // like this I want to send any type and any no of arguments as the System.out.println()
    will handle.
    My aim is to replace the System.out.println() with P.cout() which can be achieve in my idea by calling the static method ( such as cout() ) which internally use System.out.println() method. I am facing problem in achieving this because we donot know which type and how many parameters he will send .
    My task is we have to create a method which will accept any no.of arguments and is of any type.I think this can be done BY USING TEMPLATES.
    So please understand my problem and send me reply.I am waiting for your reply.
    thank you.

    Although I am not sure why you are doing this, if you really are trying to code a replacement for System.out.println then:
    out is a PrintStream and the println methods of PrintStream have the following signatures:
    void println()
    Terminate the current line by writing the line separator string.
    void println(boolean x)
    Print a boolean and then terminate the line.
    void println(char x)
    Print a character and then terminate the line.
    void println(char[] x)
    Print an array of characters and then terminate the line.
    void println(double x)
    Print a double and then terminate the line.
    void println(float x)
    Print a float and then terminate the line.
    void println(int x)
    Print an integer and then terminate the line.
    void println(long x)
    Print a long and then terminate the line.
    void println(Object x)
    Print an Object and then terminate the line.
    void println(String x)
    Print a String and then terminate
    So you should only need to create corresponding methods.

  • Compile error when using System.out

    Hello,
    I have a static part (declarative, comes within <%! %>) inside a jsp. When i use System.out.println inside this, it throws me error. Let me know what is the reason for the same.
    Thanks, Aravinth

    Hi Aravinth.
    You it self told that <%! %> is a declarative statement then how you can give a output statement.
    <%! %> It includes only declarative statements.
    And also System.out.println can't be used in Jsp since it is a implicit object.out is already declared is jsp as implicit object.You can use it as out.println();in <%%>.
    Try to avoid scriplets in jsp.
    regards,
    satheesh kannan

  • Want the "System.out.println()" that is within the java stored procedure works?

    hello
    i write a java stored procedure,and put a line as "System.out.println(...)" within the procedure,after publish it,i can test it within the sqlplus by invoke following command:
    SQL>set serveroutput on;
    SQL>call dbms_java.set_output(....);
    but when i test it within the jdeveloper9.0.3,it can't be print,why?
    thank you!

    You can try this:
    DBMS_OUTPUT.enable(100000);
    DBMS_JAVA.set_output(100000);
    HTH,
    Robert

  • Tomcat Servlet: System.out.println in servlet not printing to catalina.out

    Hello friends ,
    When i m using System.out.println() in servlet its o/p should come in catalina.out but its not coming plz help me....one thing more can we replace exixting catalina.out file with new one...
    please Help me soon.
    Thanks

    go to[u] TOMCAT_DIR/config/server.xml.
    Open this xml file and find something like <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="catalina_log." suffix=".txt"
                  timestamp="true"/>and
    <Logger className="org.apache.catalina.logger.FileLogger"
                     directory="logs"  prefix="localhost_log." suffix=".txt"
                timestamp="true"/>You can change the log file name to another one.
    It's much better to use a logger tool like log4j (http://logging.apache.org/log4j/docs/download.html) then using a System.out.println()...
    hope that helps

Maybe you are looking for

  • Display page numbers in Acrobat Pro 9

    I was just upgraded to Acrobat Pro 9. On my previous version of Acrobat, when viewing a multi-page PDF there was a field at the bottom of the page that said that I was on "Page X of Y". I deal with a lot of large documents, and I need to be able to t

  • BI 7 object field restrictions report

    Hi, Can someone please assist me.  We are working on BI7, and I have created my restriction objects for the roles in RSECADMIN.  I'm now trying to find a list of objects (and roles) that have 0CO_AREA as a restriction field. Can someone advise on how

  • Table width are different for IE, than with MZFX & GLE

    Hi everyone, I have three tables and would like them to be the same width (for looks). I tried the following: #code_selection { width:50px; margin-left:30%; #wash_type { width:398px; margin-left:30%; #wash_schedule { width:398px; margin-left:30%; In

  • Output device in condition records (Invoice)

    Hi everybody, I selected an output device in the condition records of invoices. but it's not working. The system print the document in the printer defined in SU01. However, when i delet the output device defined in defaults in SU01. the message can n

  • How to make a Discussion Forum like this one with Oracle Portal Applications

    Hallo, My colleagues and I are trying to make somthing similar for our planned intranet-platform and I wonder if there are some prefabricated modules which can be used (we are all enthused by the features of your Discussion Forums). Maybe you can pro