1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/* Java String Length Example This example shows how to get a length of a given String object. */ public class StringLengthExample { public static void main(String[] args) { //declare the String object String str = "Hello World"; //length() method of String returns the length of a String. int length = str.length(); System.out.println("Length of a String is : " + length); } } /* Output of a program would be: Length of a String is : 11 */ |
i need sample progrm not just like explaining it..i need code plz..before thursday..
hi i m new to java!!
and one of our tasks to create a program to count the number of words in a string and the number of Characters in that string..
can any one let me kw where i mistaken??
i hv create the prog but it takes a dot as a chacater what to do??
i need the codes not the explanation…… T_T
public class Sum{
public static void main(String args[]){
int sumOfFirstFiveNumbers = 0;
int temp = 1;
while(temp <= 5){
sum = sum + temp;
temp++;
}
System.out.println(sum);
}
}
I want to see only the statements of java program not the whole program.
Write a program that prompts the user to input an integer and the output the number with the digits reversed. For example if the input is 12345, the output should be 54321
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mobileapplicationlicthomepractice.CoreJavaDay1Assignment;
/**
*
* @author Md.Asiful
*/
public class IntReverse {
public int reverse(String original)
{
int length=original.length();
String reverse=””;
for (int counter =length-1; counter>=0; counter–)
{
reverse=reverse+original.charAt(counter);
}
int convertToInt=Integer.parseInt(reverse);
return convertToInt;
}
}
can anyone here help me and give me an example program for while , do while program? pls .. thanks