0% found this document useful (0 votes)
106 views3 pages

Java Coding Basics for Beginners

This document contains an introduction to the Bluej programming environment and includes code examples and explanations. It demonstrates how to calculate square roots and powers in Java using Math functions, check the size of integer types, and write a program to find the longest word in a sentence by splitting the sentence on spaces and comparing word lengths.

Uploaded by

satyender mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views3 pages

Java Coding Basics for Beginners

This document contains an introduction to the Bluej programming environment and includes code examples and explanations. It demonstrates how to calculate square roots and powers in Java using Math functions, check the size of integer types, and write a program to find the longest word in a sentence by splitting the sentence on spaces and comparing word lengths.

Uploaded by

satyender mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Bluej

Wednesday, November 30, 2022 7:57 PM

double d = Math.pow(625, 1/2) + Math.sqrt(144);


d
13.0 (double)

System.out.print("\nSize of x: "+Integer.SIZE);

New Section 1 Page 1


double y = Math.sqrt(24-25);
y
NaN (double)
double m = y + 10;
m
NaN (double)

import java.util.*;

/**
* Write a description of class LongestWord here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class LongestWord
{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int i, indx;
String sent, word, maxword="";
System.out.print("\fEnter sentence : ");
sent = sc.nextLine().trim() + " ";
for(i = 0; i < sent.length(); i = indx+1){
indx = sent.indexOf(" ", i);
word = sent.substring(i, indx);
if(word.length() > maxword.length()){
maxword = word;
}
}
System.out.print("\nLongest word : " + maxword +
"\nAnd its length is : "+maxword.length());
}
}

New Section 1 Page 2


New Section 1 Page 3

You might also like