≡ Menu

The 5 Basic Concepts of any Programming Language – Concept #4

Welcome back to our fourth lesson in our five part series on the 5 basic concepts of any programming language.  Today’s concept is syntax.

  1. Variables
  2. Control Structures
  3. Data Structures
  4. Syntax
  5. Tools

What is syntax?  As always, let’s hop over to wiki for a quick definition:

In computer science, the syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language.

Alright, so I would say that’s almost English, but what do they mean by “combinations of symbols that are correctly structured”?  Well, I would choose a different word than symbols.  I would define syntax to be a particular layout of words and symbols.  An example of this in the case of Java would be round brackets (), curly brackets {}, and variables, among other things.  Think of it like this, when you look at an email address (i.e. john.smith@company.com), you can immediately identify the fact that it’s an email address right?  So why is that?  Why does your brain make the connection that it’s an email address, and not, say, a website address?  Well, it’s because an email address has a particular syntax.  You need some combination of letters and numbers, potentially with underscores (_) or periods (.) in between, followed by an at (@) symbol, followed by a website domain (company.com)  That is a defined combination of letters and symbols that are considered correct structure in the “language” of the internet and email addresses.  So, syntax in a programming language is much the same, there are a set of rules that are in place, which when you follow them, allows your programming language to understand you and allow you to create some piece of functioning software.  But, if you don’t abide by the rules of a programming languages’ syntax, you’ll get errors 🙁

How about an example of syntax in Java?  Well you’ve seen it already back when we talked about variables and control structures.  To define a variable in Java, you need to do this:

String helloVariable = "Hello Everyone!";

There are four parts to the syntax of creating a variable in Java.  The first is the word String, this is the variable’s type.  Remember when we talked about variable types in the first part of this series?  I mentioned String, Integer and Double, three different variable types that allow you to store three different kinds of data.  A String in this case, allows you to store regular letters and special characters.  The second part to this variable creation syntax is the variable name, in this case I arbitrarily chose helloVariable.  I could have just as easily chosen holyCowThisIsAVariableName.  Variable names can be made up of letters and numbers, but the only special characters they can contain are underscores (_).  They also usually start with a lower case letter, they don’t have to, but that’s kind of an accepted and suggested convention (at least in the Java world).  The third part of the syntax for creating a variable is the value that the variable will hold.  In this case, we have a String variable, so we have the value "Hello Everyone!".  In java, Strings are defined by wrapping regular letters/numbers/special characters in quotes (” “).  Again, that’s just the syntax that Java uses.  The last part of this syntax, is the part that marks this particular code segment as being complete.  In Java, we use the semi-colon (;) to mark a part of our code as complete.  You will see that almost every line of code in Java will end with a semi-colon (;).  There are certain exceptions to this, for example control structures aren’t marked with semi-colons, as they use curly braces to make their beginning and end.  Think of it like putting a period at the end of every sentence.  If we didn’t put a period, we would just have one long unstructured run on sentence, and that wouldn’t help us to understand anything that’s being said.

So, as I mentioned before, the syntax of any programming language will likely be your biggest hurdle as a new developer, but as you see more and more examples of code and are introduced to more and more syntax in the language, you will become comfortable.  There is good news though, as people have realized that dealing with syntax can be tough, so certain companies (or groups of enthusiasts, a.k.a nerds) have created tools to help us with the syntax of programming languages.  These tools are called IDEs, or, Integrated Development Environments, which you can download onto your computer and use to create programs.  These IDEs have built in syntax checkers (much like the grammar checker in MS Word) that will let you know if your syntax is incorrect, and will even give you hints with what it thinks you meant to put!  So don’t you worry, I’ll cover those tools in the next section of this 5 part series.

Want Free Access to my Best Java Courses?

Alright, so if you’re read this far down the article, then you’re clearly interested in learning how to code. You can currently get access to my 2 best courses on Java for free for 30 days (then it’s just $10/month afterwards, or $97/year).

When you sign up you’ll receive login information to start learning about Java. If you decide you don’t like the courses, you can cancel at any time. If you decide you love the courses then you don’t have to do anything and you can stay subscribed for as long as you like for just $10/month or $97/year.

It’s like Netflix for coders!

Go ahead an click the button below to get started!

So, let’s sum up.  In today’s post, we have learned that syntax just means that there’s a “correct” way to write down your code, and that this allows the programming language understand what it is that you’re trying to tell it to do.  Unfortunately for us, computer’s can’t read our minds (yet!) and know what it is that we want them to do, so some very smart people have created this “computer language” that, when understood by programmers, allows us to tell the computer what actions we would like it to carry out… whether that action be to send a bill payment to our credit card company, or to play a game of poker online with a virtual table full of strangers.  Syntax is our systematic way to talk to a computer and convey our wishes.

I hope I have taken a little bit of mystery out of the term syntax, and I look forward to teaching you about our final subject… tools!  A developer’s best friend 🙂

Plenty of Ways to Learn

  • COMMUNITY – Learning with a community is the best way to ensure accountability and support when you need help. Coders’ Campus is a brand new community that is dedicated to new programmers like you!
  • BLOGS – If you feel like you enjoy the way this information is laid out in blog format, then I invite you to click on the “next” button below.
  • BOOKS – If you feel like you are better at learning from a book, then I invite you to check out my ebook via http://javapdf.org. This eBook is organized, and packed full of easy to follow tutorials and videos.
  • VIDEOS – If you feel like you prefer learning by watching Videos, then check out the Java Video Tutorials website. It’s full of fun and easy to follow video tutorials. So far the students enrolled in this video course have rated it 9.5/10!
  • PODCASTS – Finally, if you prefer to learn by just listening, then there’s also a podcast available on iTunes via How to Program with Java Podcast.
{ 41 comments… add one }
  • Trevor Page July 11, 2012, 9:11 am

    Thanks Katelyn, I appreciate the feedback!

  • Clint Montaivo July 11, 2012, 8:28 pm

    Plenty of exceptional creating the following. Only if I had discovered this particular website more rapidly. Congrats!

    • Trevor Page July 11, 2012, 8:36 pm

      Thanks very much Clint, I aim to please, so I’m thrilled that you feel that way. Keep coming back for more content, I’m trying to post every few days with new stuff. If you want to stay up to date, I’ve added a way to sign up to my mailing list at the bottom of my posts, so I’ll let you know when new content goes live right away!

      Have a great day

  • Roseanna Theophilus July 14, 2012, 9:31 pm

    Thank you for making this site so easy to find info. good stuff. Saving this one for later.

  • magnetron July 22, 2012, 5:13 pm

    I am glad to be one of the visitors on this great web site (:, thanks for posting .

  • Kapila August 9, 2012, 12:37 am

    I like the simplicity in these lessons and the examples used. Very easy to read and understand.

  • MM August 9, 2012, 11:52 am

    Really helpful stuff trevor! Can’t wait to see more. 🙂

  • Six String August 30, 2012, 4:07 pm

    hey man, i love your style! like, you make it seem easy as pie, I’ve checked TONS of programming tutorials, and yours is the most intellectual from a beginners point of view, not just that, a lot of programmers even don’t have a breif idea about things..anywho, keep up the great work, we are always grateful (y) :]

    • Trevor Page August 30, 2012, 4:25 pm

      Thanks very much, it’s always great to get such positive feedback!

      Keep checking in every week or so for new posts on new topics 🙂

  • Aruna September 5, 2012, 11:02 am

    I like this and it is very cool.expecting a lot from you

    • Trevor Page September 5, 2012, 1:49 pm

      Thanks Aruna!

      I’m expecting to deliver a lot, so stay tuned 🙂

  • Marcin September 25, 2012, 1:14 pm

    Great way to start learning java…This is awesome for beginners – very easy to understand all these concepts… Keep writing more Trevor!

    • Trevor Page September 25, 2012, 1:57 pm

      My pleasure Marcin,

      Let me know how your journey goes in learning Java, I’m here to help!

  • salles nicco January 25, 2013, 7:14 am

    thanx Trevor, here in Africa u’d learn stuff lyk thc only in university bt nw with thc syt of urz its so simple!

  • doublechyke February 16, 2013, 4:15 am

    Thank you so much. It was so clear!

  • farheen April 21, 2013, 7:50 am

    Thank you so much…i m really enjoying learning java through your site, expecting lot from you keep writing more…:)

    • Trevor Page April 21, 2013, 9:00 am

      Thanks for you comment Farheen.
      I still post content weekly (whether it’s a blog post or a podcast episode). I don’t see myself stopping anytime soon 🙂

  • Pavan July 28, 2013, 1:09 pm

    Thanks for great stuff. Yours study material is easy to understand for beginners like me…. I’m really enjoying java.. Yours is the best tutorial compared to other website tutorials… you are having a very good style of explanation…

  • chala diriba December 27, 2013, 3:18 am

    you have helped me so much.thankyou and continue please

  • chala diriba December 27, 2013, 3:19 am

    10q really

  • Joy July 8, 2014, 5:10 am

    Awesome Teaching…!!
    Really, so simple and understandable Examples..
    Thank You..

  • Mitch July 21, 2014, 5:59 pm

    Came across this site to learn the basic concepts and ended up learning much more than that. thanks for the awesome site. 🙂

    • Trevor Page July 24, 2014, 9:02 am

      Great to hear Mitch, always nice to see someone eager to learn!

  • Arpit Dadhich February 5, 2015, 7:02 am

    Great teaching skills!
    I felt like I’ve been your student for a while, Trevor.

    Decided to learn C language and wish you could at least guide me to a link or something where i can find a good eBook? or a free C programming course?

    thanks for the concepts anyway, cheers!

    • Trevor Page February 7, 2015, 11:09 am

      Glad to hear you’ve been sticking around with me for a while.

      I’m really sorry to say that I have absolutely no experience with C, C++ or C#. I therefore have nothing in terms of an exact book to recommend. Your best bet is to just go through Amazon and look through the reviews on books, see what people are saying they like and dislike about the books

  • deborah September 1, 2015, 1:58 pm

    I love the way you explain things. It makes more sense then trying to read the text book. So thanks for the website.

  • Muhammad Muzammil September 22, 2015, 1:20 pm

    Thankx Alooot for the stuff… you provide for the bigneers….

  • Dhanvanthi January 14, 2016, 11:43 pm

    Hi Trevor,

    I am novice to the programming language. I Java as one of the subjects in my career and wanted to learn it and fortunately came across your website. I am thankful to you for having such a wonderful site. I wish I had seen this before would have helped me learn faster. But better to be late as a quality person than a dumbo.
    Your teaching shows that you have very in depth knowledge of the language. Please share how did you do it? I want to gain much knowledge in Java programming because I love it. Can you please help me to come up in programming and become a master.
    Of course I can’t reach up to your level because you are the top most Genius. Is it okay if I keep visiting your website?

  • Ahmed hassan February 14, 2016, 7:05 am

    I really enjoy u

  • Anonymous February 25, 2016, 12:47 am

    which software do i need on my computer which allows me to type in when i am learning. I know nothing bt i think i can start here. If u don’t want to tell me here, lagopower2011@gmail.com

    • Trevor Page February 25, 2016, 10:34 am

      I don’t understand the question. Can you elaborate?

  • Beverly Mascoe May 17, 2016, 8:15 am

    I just have to tell you this has been incredibly helpful to me! I am a 60 year old nurse with not much computer experience and you have made this so easy to understand! I am taking an aptitude test this morning for a new position. Part of it is related to computer programming. I feel much more confident after reading this. Thank you for making it relevant.

  • jenalyn August 2, 2016, 11:14 pm

    different application of operator in java programming

  • Olusegun November 25, 2016, 2:47 pm

    Hi Trevor, pls which programming language would you suggest a beginner to learn first?

  • Ana January 23, 2017, 5:43 am

    You’re just great! And trust me, I’ve tried to get information and to understand all you said from a lot of other sites.
    Thanks a lot!

  • Frank Carr October 13, 2017, 12:39 pm

    I used to program in Basic 1990.
    I have forgotten the syntax structure, IE the computer recognises numbers; capitals then lowercase,is this correct.
    so any written program should bear this in mind.
    Am I correct.

  • adekola October 22, 2017, 5:39 am

    well nice one keep it up

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.