• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get the 1st letter of a input(String) and compare it to a single letter before insert to DB  RSS feed

 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
example i have code and name but my code must start with the first letter of the inputed name if the 2 input is match it will be inserted into database

code = "A"001
name ="Angela"
= sucess this will inserted into database

else

code ="B"002
name="Angela"
=failed this will not inserted into database

else

code="A"003
name="Andy"
=sucess still accepts the input cause they have diff code number

help, what im thinking on this was compare the code the name? if == it will be inserted but how do i get the 1st letter of the input name?
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String#charAt(0)?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I fail to see how your second example (code = B, name = Angela) is a success given the description you have supplied.
Is this a mistake or is there more to this problem than you have explained?
 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:Sorry but I fail to see how your second example (code = B, name = Angela) is a success given the description you have supplied.
Is this a mistake or is there more to this problem than you have explained?


my bad i already change it into failed
 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:String#charAt(0)?


thank you i already tried it on w3c and it works will apply this later on my junit testing
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API docs are your friend.
 
chrstian ferma
Ranch Hand
Posts: 72
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks man i will read more about api docs
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!