- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check whether String is an interface or class in Java
The method java.lang.Class.isInterface() is used to find if String is an interface or class in Java. This method returns true if String is an interface, otherwise it returns false.
A program that demonstrates this is given as follows −
Example
package Test; import java.lang.*; public class Demo { public static void main(String[] args) { Class c = String.class; boolean interfaceFlag = c.isInterface(); System.out.println("This is an Interface? " + interfaceFlag); } }
Output
This is an Interface? false
Now let us understand the above program.
The isInterface() method is used to find if String is an interface or not. The result is stored in interfaceFlag and then displayed. A code snippet which demonstrates this is as follows −
Class c = String.class; boolean interfaceFlag = c.isInterface(); System.out.println("This is an Interface? " + interfaceFlag);
Advertisements