Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Java substrings are easy! 📧
Play lesson

Java tutorial for beginners ☕ - Java substrings are easy! 📧

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse This is a beginner's introduction to substrings and we'll use it to code an email slicer that extracts a username and domain from an email address. import java.util.Scanner; public class Main { public static void main(String[] args) { // .substring() = A method used to extract a portion of a string // .substring(start, end) Scanner scanner = new Scanner(System.in); String email; String username; String domain; System.out.print("Enter your email: "); email = scanner.nextLine(); if(email.contains("@")){ username = email.substring(0, email.indexOf("@")); domain = email.substring(email.indexOf("@") + 1); System.out.println(username); System.out.println(domain); } else{ System.out.println("Emails must contain @"); } scanner.close(); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere