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

Interpreting a variable - Java Tutorial

From the course: Java Design Patterns: Behavioral Part 1

Start my 1-month free trial

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…

Contents