Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple questions about AWT and Assertions

 
Wenyu Deng
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody can tell me, what is the full name of AWT and Assertions? and what are they mean? thanks a lot.
----waiting for your feeback.
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I'm wrong, but AWT stands for Abstract Windowing Toolkit... All of the GUI components (e.g. windows and buttons) are designed to utilise native code, hence displaying like your normal windows under any OS (i.e. in Windows, they will display as normal Windows windows do [that phrase is confusing!], and under Linux they will display in a Linux-style format). Often now, many programmers use the Swing components (in package javax.swing), as they supply additional and improved components - and will always display the SAME across any platforms.
Assertions are used (as any concurrent programmer of J2SE 1.4 will tell you) to verify that certain statements that MUST BE TRUE are met, or that points in code that should never be reached are not... For example, suppose that you have a switch statement, and the int passed as the argument should match one of the cases exactly. You may use an assertion in the default case, to verify that if the code is reached, the program will terminate (as technically it should never be reached).
They may also be used to verify that a particular variable or method returns a value that MUST be correct.
Note that assertions are disabled by default, to enable backward compatibility with code that used variable names (identifiers more technically) called 'assert'. The structure of an assert statement is effectively:
assert <statement> : <message>;
If the <statement> returns the boolean value false, the program (assuming assertions enabled) will terminate, with an optional String message <message>. There are several APPROPRIATE uses of assertions, and uses which are NOT - certainly this is required information for the SCJP 1.4 exam.
 
Wenyu Deng
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, i got it.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Wenyu!
For more information on assertions in Java, take a look at the September 2002 JavaRanch Newsletter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic