Author Topic: Paano po ba gamitin ang substring sa java?  (Read 64 times)

0 Members and 1 Guest are viewing this topic.

Offline MoneyRepublic

  • Full Member
  • *
  • Posts: 166
  • Karma: +0/-0
    • View Profile
Paano po ba gamitin ang substring sa java?
« on: July 21, 2016, 05:10:26 AM »
Pano po ba gamitin ang substring?

Techronnati | where technology never sleeps

Paano po ba gamitin ang substring sa java?
« on: July 21, 2016, 05:10:26 AM »

Mountain View

Offline LadyProgrammer

  • Full Member
  • *
  • Posts: 118
  • Karma: +0/-0
    • View Profile
Re: Paano po ba gamitin ang substring sa java?
« Reply #1 on: July 21, 2016, 06:42:35 AM »
A substring returns a substring of a string. Pretty straightforward, right? :)

Eto ang mga syntax nya:

Code: [Select]
substring(int beginIndex)
substring(int beginIndex,int endIndex)

Eto ang sample code using substring:

Code: [Select]
String subString1 = "Pinoy Java Tutorial by Mau Dim Jr";
System.out.println(subString1.substring(6));
System.out.println(subString1.substring(6, 10));

Sa unang print, ang lalabas ay "Java Tutorial by Mau Dim Jr". Kaya yun ang lumabas kasi isa lang ang pinasa natin na arguement ("6"). At dahil dun, from sa pang 6 na character hanggan sa dulo ng string. Kaya yan ang lumabas. Kindly note na ang unang character sa string ay index 0. Kaya ang pang 6 na character ay "J" kaya dun sya nagstart.

Sa second print, ang lalabas ay "Java". Kaya yun ang lumabas kasi dalawa yung arguement na pinasa natin ("6, 10"). At dahil dun, from sa pang 6 na character hanggan sa pang 10 lang ang kukunin nya.

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
207 Views
Last post November 11, 2016, 02:08:31 AM
by JusticeLeague
0 Replies
121 Views
Last post October 21, 2014, 12:59:44 AM
by JusticeLeague
0 Replies
45 Views
Last post July 14, 2016, 06:06:54 AM
by nomadic
0 Replies
54 Views
Last post July 21, 2016, 02:14:09 AM
by rpmolecule
0 Replies
159 Views
Last post August 11, 2016, 02:11:18 AM
by LadyProgrammer

Posting Disclaimer: Any individual may post a message in this forum and may do so anonymously. Therefore, the sole author is exclusively and entirely responsible for all opinions in that message. They do not represent the official opinions of Techronnati, its administrators or moderators or the Techronnati Management. Techronnati is merely acting as an impartial conduit for constitutionally protected free speech and is not responsible and will not be held liable for the content of such messages. All images and service logos are trademarks of their respective owners.