Solved

textfield = null?

Posted on 1997-06-30
2
680 Views
Last Modified: 2006-11-17
I'm a Java newbie and have tried the following code in both VisualAge and Visual Cafe:

if (TextField1.getText() = null) //also tried if == ""
   then do something...

Although there is no text in the textfield, the above code
acts as though it is false and won't 'do something...'
What is the proper syntax to find out if a textfield is blank?
0
Comment
Question by:scheide
2 Comments
 
LVL 1

Accepted Solution

by:
mann061997 earned 50 total points
ID: 1222531
Use this statement:

  if (TextField1.getText().length() == 0) {
      //then do something...
  }

or

  if (TextField1.getText().equals("")) {
      //then do something...
  }

0
 

Author Comment

by:scheide
ID: 1222532
Clear and concise answer...I assume it works and will test it.
Thanks...and boy do I feel silly/stupid. :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now