Home » Java programming language

Java StackTraceElement isNativeMethod() method with example

StackTraceElement Class isNativeMethod() method: Here, we are going to learn about the isNativeMethod() method of StackTraceElement Class with its syntax and example.
Submitted by Preeti Jain, on December 24, 2019

StackTraceElement Class isNativeMethod() method

  • isNativeMethod() method is available in java.lang package.
  • isNativeMethod() method is used to check whether the method is native or not that contains the execution point denoted by this StackTraceElement.
  • isNativeMethod() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • isNativeMethod() method does not throw an exception at the time of checking the native method.


    public boolean isNativeMethod();


  • It does not accept any parameter.

Return value:

The return type of this method is boolean – it returns a boolean value based on the given cases,

  • It returns true when the method that contains the execution point denoted by this StackTraceElement is native.
  • It returns false when the method that contains the execution point denoted by this StackTraceElement is a non-native method.


// Java program to demonstrate the example 
// of boolean isNativeMethod () method of StackTraceElement 

import java.util.*;

public class Native {
    public static void main(String args[]) {
        System.out.println("Native Method :");
        for (int k = 0; k < 2; ++k) {
            // check native method in a thread by using
            // isNativeMethod () method
            System.out.print(Thread.currentThread().getStackTrace()[k].getClassName() + " ");


Native Method :
java.lang.Thread false
Native false


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.