How to import java.lang.String class in Java?



To import any package in the current class you need to use the import keyword as

import packagename;

Example

Live Demo

import java.lang.String;
public class Sample {
   public static void main(String args[]) {
      String s = new String("Hello");
      System.out.println(s);
   }
}

Output

Hello
Updated on: 2020-02-26T05:48:03+05:30

18K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements