Strings in java смотреть онлайн
For selenium training (classroom) in pune
contact : 9657852251 or
visit :http://scriptinglogic.org
Amazon India Hard Copy of book : https://amzn.to/2PuMOCK
Amazon India Kindle : https://amzn.to/2GRQR85
Amazon International Kindle : https://amzn.to/2WkO6mc
Amazon International Hard Copy of book :
https://amzn.to/2DHekbm
String is generally sequence of a character, in java it is a class. unlike c or c++ at the end of the string the ‘\0’ character is not placed in java.
String is simply defined like
String str = “myString”;
To find length of a string use length() function.
so str.length() will give me 8 as a string length. like array string also has indexes which starts with 0,
to find character at specific index use charAt(i) function where i is the index of the character.
now lets see the functionality of these 2 String fictions with the help of an example.
public class myString {
public static void main(String[] args)
{
int n=str.length();
String str1="this is a java"; // find character at 3 & length
String str2="hi i am here";// find character at 2 & length
String str3="where are you";// find character at 0 & length
String str4="this is a demo";// find character at 5 & length
String str5="core java";// find character at 6 & length
System.out.println("Character at 3 of str1 = "+str1.charAt(3) +" | Length is :" + str1.length());
System.out.println("Character at 2 of str2 = "+str2.charAt(2) +" | Length is :" + str2.length());
System.out.println("Character at 0 of str3 = "+str3.charAt(0) +" | Length is :" + str3.length());
System.out.println("Character at 5 of str4 = "+str4.charAt(5) +" | Length is :" + str4.length());
System.out.println("Character at 6 of str5 = "+str5.charAt(6) +" | Length is :" + str5.length());
}
}
output:
Character at 3 of str1 = s | Length is :14
Character at 2 of str2 = | Length is :12
Character at 0 of str3 = w | Length is :13
Character at 5 of str4 = i | Length is :14
Character at 6 of str5 = a | Length is :9
We can convert string to upper case and lower case too using toUpperCase() and toLowerCase() functions. Consider below example.
public class JavaPrograms {
public static void main(String[] args)
{
String str1="this is a java";
String str2="HI I AM VIPULA";
System.out.println("Str1 is:'"+str1+"'");
System.out.println("Str1 in lower case:'"+str1.toUpperCase()+"'");
System.out.println("Str2 is:'"+str2+"'");
System.out.println("Str2 in lower case:'"+str2.toLowerCase()+"'");
}
}
output :
Str1 is:’this is a java’
Str1 in lower case:’THIS IS A JAVA’
Str2 is:’HI I AM VIPULA’
Str2 in lower case:’hi i am vipula’
Another more important function of string is subsring, it has 2 forms
substring(int beginIndex) : it will return a string starting with beginIndex till the end of the string
substring(int beginIndex,int endIndex) : it will return a string starting with beginIndex till the endIndex (practically if you seeyou will observe that in this case the substring starts with the startIndex and it takes till next (endIndex-startIndex) characters. e.g. if i am taking str.substring(3,9) the string will start from 3rd index and will take till (9-3=6) i.e. till next 6 characters.)
Let us understand this with example
public class mySubString {
public static void main(String[] args)
{
String str="this is ajava";
System.out.println(str.substring(3));
System.out.println(str.substring(3,9));
}
}
output :
s is ajava
s is a
Another important function of String is split. its syntax is str.split(“ch “). it will return an array of a string spitted by the character you specify inside spit. lets understand this with the help of example.
public class SplitFunction {
public static void main(String[] args)
{
String str="this is a java";
String[] strArr = str.split(" "); // split by space.
System.out.println("Given String is '"+str+"'");
System.out.println("There are total "+strArr.length+ " words separeted by space");
for (int i=0;i﹤strArr.length;i++)
{
System.out.println(strArr[i]);
}
System.out.println("_____________________________");
String str1="12-2-2016";
System.out.println("Given String is '"+str1+"'");
String[] strArr1 = str1.split("-"); // split by space.
System.out.println("There are total "+strArr1.length+ " words separeted by -");
for (int i=0;i﹤strArr1.length;i++)
{
System.out.println(strArr1[i]);
}
}
}
output:
Given String is ‘this is a java’
There are total 4 words separeted by space
this
is
a
java
___________________________
Given String is ’12-2-2016′
There are total 3 words separeted by –
12
2
2016
Lets see one more example on this. consider a string “Hey baby you are so sweet” find out the words in this string ending with ‘y’.(dont use in built function.)
public class SplitExample {
public static void main(String[] args)
{
String str="Hey baby you are so sweet";
String[] strArr=str.split(" ");
for (int i=0; i﹤strArr.length;i++)
{
if(strArr[i].charAt(strArr[i].length()-1)=='y')
System.out.println(strArr[i]);
}
}
}
output:
Hey
bab
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Strings in java» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.