From the course: Java Design Patterns: Behavioral Part 1
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Interpreting a variable - Java Tutorial
From the course: Java Design Patterns: Behavioral Part 1
Interpreting a variable
- Now I've done all the hard work of creating the interpreters. So all I need to do is credit clients to try it out. So I'm going to create a new Java class called Main (keyboard clicking) and in here, I'm going to create a private static void Main method. In here, I'm going to create my context and my context is just going to be a string. So I'll do string context = and I want this to be something that will test all of my conditions. So it's going to begin with an underscore, then a capital letter I, and it's going to be called "Int," which is a primitive type. If my interpreter works properly, it will first remove the underscore making it Int with a capital I then make it int with a small i and then finally add a 1 to the end. So the next thing I need to do is create a local variable. We'll type FirstLetterNotUnderscore, and I'll do new FirstLetterNotUnderscore, then I can just do context = and then do…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.