473,473 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

quick question about concatenation

19 New Member
Hi.

I finished a program for a Java class I'm taking. It works properly; I just want to format it a little bit better.

I have an if-statement
if (y == 'a' || y == 'b' || y == 'c' ............... etc) that extends for a long time.

Is there anyway to easily just continue the if statement condition on the next line like you can do with string concatenation?

Thanks.
Michael
Jun 1 '07 #1
2 1010
blazedaces
284 Contributor
Hi.

I finished a program for a Java class I'm taking. It works properly; I just want to format it a little bit better.

I have an if-statement
if (y == 'a' || y == 'b' || y == 'c' ............... etc) that extends for a long time.

Is there anyway to easily just continue the if statement condition on the next line like you can do with string concatenation?

Thanks.
Michael
Hey Michael, why not just do something like:
Expand|Select|Wrap|Line Numbers
  1. switch(y) {
  2.      case 'a':
  3.      case 'b':
  4.      case 'c':
  5.      ....
  6.      case whateverCharacter: do the thing you want in the if statement; break;
  7.      default: whatever would go in else statement; break;
  8. }
  9.  
Hope that helps somewhat...

-blazed
Jun 1 '07 #2
JosAH
11,448 Recognized Expert MVP
Hi.

I finished a program for a Java class I'm taking. It works properly; I just want to format it a little bit better.

I have an if-statement
if (y == 'a' || y == 'b' || y == 'c' ............... etc) that extends for a long time.

Is there anyway to easily just continue the if statement condition on the next line like you can do with string concatenation?

Thanks.
Michael
Here's a short solution to your problem:

Expand|Select|Wrap|Line Numbers
  1. int index= "abc.......".indexOf(y);
  2. if (index >= 0) // found it
  3.  
kind regards,

Jos
Jun 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.