Results 1 to 6 of 6
  1. #1
    java java is offline Member
    Join Date
    Feb 2015
    Posts
    14
    Rep Power
    0

    Default using " System.out.println("thank you");" in android project

    hello, I created an android project with android studio and in MainActivity.java I wrote As follows:

    Java Code:
    package com.myexample.test;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
        public static void main(String[]args){
            System.out.println("thank you");
        }
    }
    The above code runs well, but I do not see "thank you " !!!!!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    15

    Default Re: using " System.out.println("thank you");" in android project

    Where do you expect it to print?

    When do you expect that main method to run?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    java java is offline Member
    Join Date
    Feb 2015
    Posts
    14
    Rep Power
    0

    Default Re: using " System.out.println("thank you");" in android project

    In fact, the default when I create an android project, a small program can be built and Its name is "hello world". but for "hello world" we use from xml. Can I use " System.out.println("thank you");" instead of "hello world" to display at the same location from screen?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: using " System.out.println("thank you");" in android project

    I have no idea where "out" points to on an Android system, but I very much doubt it's the screen.

    In addition, as Kevin asked, when do you actually expect that main() to run?
    Android does not use main() as an entry point to an Activity.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: using " System.out.println("thank you");" in android project

    On my Android device, SOP can be seen on the Logcat console.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: using " System.out.println("thank you");" in android project

    Quote Originally Posted by Norm View Post
    On my Android device, SOP can be seen on the Logcat console.
    That makes sense.
    Much more than the screen for the Activity anyway.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  2. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  3. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. Replies: 11
    Last Post: 08-19-2008, 11:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •