1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Android Studio: println の使い方

Posted at

MainActivity.kt に println を挿入

MainActivity.kt
package com.example.jpeg03

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        println("*** start ***")

        for (i in 1..5) {
            println(i)
        }
        println("*** end ***")
    }

}

実行

View -> Tool Windows -> Logcat

image.png

次のようにメッセージが表示されます。

2023-10-13 16:04:15.882  8504-8504  System.out              com.example.jpeg03                   I  *** start ***
2023-10-13 16:04:15.882  8504-8504  System.out              com.example.jpeg03                   I  1
2023-10-13 16:04:15.882  8504-8504  System.out              com.example.jpeg03                   I  2
2023-10-13 16:04:15.883  8504-8504  System.out              com.example.jpeg03                   I  3
2023-10-13 16:04:15.883  8504-8504  System.out              com.example.jpeg03                   I  4
2023-10-13 16:04:15.883  8504-8504  System.out              com.example.jpeg03                   I  5
2023-10-13 16:04:15.883  8504-8504  System.out              com.example.jpeg03                   I  *** end ***
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?