java multi 3 Answer(s) 3 years and 11 months ago
Posted in : Java Beginners
View Answers
June 17, 2009 at 4:31 PM
Hi Friend,
Try the following code:
1)import java.util.*; import java.util.regex.*; public class ShortestWord{ public static void main (String args[]){ System.out.print ("Enter a sentence: "); Scanner input=new Scanner(System.in); String str=input.nextLine(); String[] words = str.split(" "); String word="aaaaaa"; for (int i=0;i<words.length;i++){ if (words[i].length() < word.length()) word = words[i]; } System.out.println("Shortest word is: "+word); int len = word.length(); int index = 0; int start = str.indexOf(word); while (start != -1){ index++; start = str.indexOf(word, start+len); } System.out.println("Its position is: "+index); } }
Thanks
June 17, 2009 at 5:48 PM
Hi Friend,
Try the following code:
import java.util.*;
public class Digits {
public static void main(String[] args) { int oddCount=0; int evenCount=0; int zeros=0; System.out.println("Enter multi digit number."); Scanner input = new Scanner(System.in); int number = 0; int[] nums=new int[9]; while (input.hasNextInt(9)) { number = input.nextInt(); String myString = Integer.toString(number) ; nums = new int[myString.length()]; for(int i = 0; i < nums.length; i++){ nums[i] = myString.charAt(i) - '0'; } //To find number of odds for(int j=0;j<nums.length;j++) if(nums[j] % 2 == 1) { oddCount++; } System.out.println("Number of odds: "+oddCount); //To find number of evens for(int j=0;j<nums.length;j++) if(nums[j] % 2 == 0) { evenCount++; } System.out.println("Number of evens: "+evenCount); //To reverse number int reverse = Integer.parseInt( new StringBuffer( ""+number ).reverse().toString() ); System.out.println("Reverse Number = " + reverse ); } }
}
Thanks
June 18, 2009 at 1:01 PM
Hi Friend,
Use following code in your Digits.java class to count the number of zeros present in the input digit.
multi language multi language Hello friends please help me
Hi how can i do a java program using swing that changes the language like malayalam/tamil etc with languages on a drop down menu
I am using netbeans IDE
Java multi-threading Javamulti-threading What method is invoked to cause an object to begin executing as a separate thread
Java multi-threading Javamulti-threading How does multithreading take place on a computer with a single CPU
java multi - Java Beginners java multi Q. 1. Write a class with a special member function to input a multi digit number ( max. 9 digit) and print the following: (15)
1. total... of zeroâ??s present.
Q.2. Write a program in java to input a sentence and find out
Multi-Threading - Java Beginners Multi-Threading Consider a producer process prime-generator produces prime numbers randomly that are
displayed by a consumer process called prime... the previously displayed number. You have to write a
multithreaded Java program
multi threads - Java Beginners multi threads Hi i writing a multi threaded program in java .I m using three threads. I want to declare variables which will be available to all the threads to access. Is there a way to declare the variables as global variables
java multi thread - Development process javamulti thread Develop multi-threaded echo server and a corresponding GUI client in Java.please immediately reply me sir.its very urgent sir
multi threaded program - Java Beginners multi threaded program Hi i m developing a multi thread program to execute a real time algorith. I m using three threads. I want to share date between three threads .Is there a way to share data from one thread to another thread
regardoing multi threads - Java Beginners
regardoing multi threads Hi Please tell me how to declare global variables in main thread so that all other threads can use them and value will be available to all threads.
Thanks
multi threading - Java Interview Questions multi threading 1. extending a thread and 2. implementing runable interface is used in multi threading concept in both of this which one good... information over Multithreading concepts visit http://www.roseindia.net/java/thread
Multi line graph - Java Beginners Multi line graph Hi,
I want a multi line graph on a single chart using jfree in java....
Can you please let me know the code...
thanks... MultiLineChart("Multi Line Chart");
demo.pack
multi user chat server - Java Beginners multi user chat server write a multi chat server and client with step by step explanation?
please send me this source code to my mail id with step by step explanation
Multi-line cells in the JTable - Java Tutorials Multi-line cells in the JTable
2002-04-11 The Java Specialists' Newsletter [Issue 045] - Multi-line cells in the JTable
Author:
Dr. Heinz M. Kabutz... any more time, let's look at a real-life
Java problem...
Multi-line cells
multi-threaded Java program - Java Beginners multi-threaded Java program Write a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime numbers
Java Multi Dimensions Array - Java Tutorials
.style1 {
text-align: center;
}
Multidimensional Arrays in Java
In java, the grouping of same type of elements for storing under the same
name...(element);
}
}
}
Output :
C:\Program Files\Java\jdk1.6.0_18\bin>
implementing an algorithm using multi threads - Java Beginners
implementing an algorithm using multi threads Hi i need to implement an algorith in multi threads.Algorithm has data dependency so i need to pass data from one thread to another thread.
I am posting my algorithm which needs
Balance multi-way tree implimentation reating database - Java Beginners
Balance multi-way tree implimentation reating database I am doning a project in which I have to create a database product in java where user can... database like Access,MySQL.As we know database is based on Balance multi-way tree
Arrays -- Multi-dimensional Java NotesArrays -- Multi-dimensional
All arrays in Java are really linear, one-dimensional arrays.
However, you can easily build multi-dimensional arrays
from these, and Java has features in the language to help
you do
Setting Multi-Line label on the Button
Setting Multi-Line label on the Button
This section shows you how to set the multi line label
on the button in Java Swing Applications.
This program uses html class
Hi Friend...Doubt on Uni Cast & Multi Cast - Java Beginners
Hi Friend...Doubt on Uni Cast & Multi Cast Hi Friend..
Can u plz send some Details about the Uni CAst & Multi cast in JAVA... Hi... one-to-many connections, an example for multicast is the java eventhandling
Creation Time Comparison of Multi Dimensional Array- Java Tutorials
Creation Time Comparison of Multi Dimensional Array
In this section, we will compare the creation time between the different
size/dimension of array.
As you know that multidimensional array is the array of arrays. Practically
Multi Threading Multi Threading Hi...
I need to solve the following question:
Input an array of 10 integers. Separate the odd numbers, even numbers,
positive numbers and negative numbers by different threads.
I tried to solve it but I dont
multi dimension multi dimension class TwoDAgain{
public static void main(String args[]){
int twoD[][]=new int[4][];
twoD[0]= new int[1];
twoD[1]= new int[2];
twoD[2]= new int[3];
twoD[3]= new int[4];
int i, j, k = 0;
for (i=0; i<4; i
Multi window Multi window I am making a bank app using struts 1.2.
using only the struts tags and nno jsp tags and scriplets.
db connected thru dao.
1st page contains all the details.
when i submit this page, a new window opens and asks
Multi-dimensional arrays
;
The Java programming language does not really support multi-dimensional arrays...
Multi-dimensional arrays
 ...-dimensional arrays. To store data in more dimensions a multi-dimensional
array is used
what is multi-threading .?
what is multi-threading .? what is multi-threading.what is the use in real time, with example programs
Multi value data - JDBC Multi value data Hello,
please help,how do i use Multi-value data with mysql database.
thank you Hi friend,
Plz explain your problem in details what you want and visit to :
http://www.roseindia.net/jdbc/jdbc
Multi-value data - JDBC Multi-value data hey!
actually am supposed to create this database that allows multi-value data.its supposedly going to become a very large database.only i dont know just how to begin creating it.what i need is mysql syntax
Multi PortType in NuSOAP - WebSevices Multi PortType in NuSOAP I would like to create a SOAP Server with atleast 2 PortType UserPortType and AccountPortType my problem is I cant combine both 2 PortType in the same Server page
sendimg multi sms
sendimg multi sms i want to send multiple sms from a distribution list decleared in the server...how do i connect my code to server
Multi-Date Handling Problem Multi-Date Handling Problem In our project we are using Oracle 10g as our data base, the problem is that we are picking In-date & Out-date from a calendar and on the basis of that date we are checking that on that date some
Multi-threaded Programming Multi-threaded Programming Write a class resourceThread which has a method run which calls display method of resource class. Resource class has synchronized display method which prints the array string. Take a string
Multi Threading is not working in that why...? Multi Threading is not working in that why...?
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
public
multi client mobile chat application multi client mobile chat application plz help me for creating wap based mobile chat application in neatbean. or simply multi client mobile chat application. its urgently thanx
Multi Clipboard Multi Clipboard
Multi Clipboard gives you a clipboard for text... some
snippets by adding them to the Multi Clipboard and then paste any of them... of
your Multi Clipboard to a file when Eclipse is closed. Contents
multi client mobile chat application
mobile chat application plz help me for creating wap based mobile chat application in neatbean. or simply multi client mobile chat application
multi client mobile chat application
chat application for mobile plz help me for creating wap based mobile chat application in neatbean. or simply multi client mobile chat application. its urgently thanx
comparing arraylist of an multi dimensional arraylist
comparing arraylist of an multi dimensional arraylist can anyone help me in solving the following issue:
actually i have an arraylist called dany under which there are 89 more arraylist.each of them contains some values.now i
Java MultiThread Java has multithreading feature.
Multithreading feature is given by Thread class and Runnable
interface
Java Multithreading allows to run multiple tasks(threads) at a time.
JavaMulti Thread Example
public class multi
JFreechart multi line chart help in JSP
JFreechart multi line chart help in JSP Hi,
I am am looking for and help in getting multi line chart with Jfree chart, i had manage to write a singe line chart but i need multy line can you please help.
<%@page
java
java how to add two child threads in multi thread in java
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array hi, if v r using Arrays.asList() means, it may shuffle the row wise list only... v want to shuffle the ful entire multi-simensional array means wat v want to do
Java Method Synchronized Java Method Synchronized
The Java language Program supports multi threads. The synchronized is a
keyword used in Java ensures that only one Java thread execute an object's