Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

textfield = null?

Posted on 1997-06-30
2
Medium Priority
?
693 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
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 …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

885 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