What are semantics in Java?
1)Syntax refers to formal rules governing the construction of valid statements in a language. Semantics refers to the set of rules which give the meaning of a statement.
2) Errors due to syntax occur in a program when ruels of the programming language are violated or misused. Errors due to semantics occur in a program when statements are not meaningful.
3) Word order is the basic principal of syntax, those trying to understand what is written use the syntactic cues of word order to help give the sentence structure and meaning. Semantics are an individuals own interpretation of the meaning of a "sentence" based on their prior knowledge. Therefore a sentence that seemingly makes no syntactic sense, can have meaning when using semantic cues.
4) Syntax is only concerned with what is linguistically and grammatically correct. Semantics requires all ones prior knowledge which, and is far beyond anything which is language specific.
5) The sentence "Baby milk drinks" does not have a syntactic meaning, but through semantics most people would interpret it as meaning " Baby drinks milk " as our prior knowledge tells us that a baby drinks milk, and therefore we can find a meaning from the key words.
Traffic stats