Solved

textfield = null?

Posted on 1997-06-30
2
678 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

747 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

12 Experts available now in Live!

Get 1:1 Help Now