Is there any simple method of string multiplication in java ..?

View Answers

February 13, 2012 at 3:25 PM

public class StringMultiplication { public static void main(String[] args) { String number1 = "17"; String number2 = "15"; char[] n1 = number1.toCharArray(); char[] n2 = number2.toCharArray(); int result = 0; for (int i = 0; i < n1.length; i++) { for (int j = 0; j < n2.length; j++) { result += (n1[i] - '0') * (n2[j] - '0')* (int) Math.pow(10, n1.length * 2 - (i + j + 2)); } } System.out.println(result); } }

February 13, 2012 at 3:25 PM

import java.math.*; public class StringMultiplication { public static void main(String[] args) { String number1 = "17"; String number2 = "15"; BigInteger num1=new BigInteger(number1); BigInteger num2=new BigInteger(number2); BigInteger result=num1.multiply(num2); System.out.println(result); } }

Ads

Related Tutorials/Questions & Answers:

java string multiplication Is there any simple method of string multiplication in java ..? public class StringMultiplication { public static void main(String[] args) { String number1 = "17"; String number2

Parallel multiplication matrix in java hello dear I need parallel multiply matrix in java algorithm to account speed up and efficiency great wishes

Advertisements

multiplication algorithms in java divide and conquer I need multiplication algorithms in java divide and conquer ask from user input two numbers in binary then the program multiply two number use multiplication algorithm in java

multiplication algorithms in java divide and conquer I need multiplication algorithms in java divide and conquer ask from user input two numbers in binary then the program multiply two number use multiplication algorithm in java

multiplication algorithms in java divide and conquer I need multiplication algorithms in java divide and conquer ask from user input two numbers in binary then the program multiply two number use multiplication algorithm in java

java program_big digits multiplication.. i want program about big digits multiplication program using java..plz tel me answer

code for multiplication of matrix in java using methods code for multiplication of matrix in java using methods

multiplication multiplication of two number numbers entered by user minimum 100digits using GUI Java Multiplication of two 100 digits... java.awt.event.*; class SwingMultiplication { public static void main(String

multiplication multiplication of two number numbers entered by user minimum 100digits using GUI Java Multiplication of two 100 digits... java.awt.event.*; class SwingMultiplication { public static void main(String

Matrix Multiplication in Java In this Java tutorial we will demonstrate you 'Matrix Multiplication in Java' with the help of a simple example from which you can easily learn how to write a matrix multiplication program in Java

Matrix multiplication in java In this section we will learn about multiplication of two matrices. In java this is a simple program to multiply two matrices... main(String args[]) { int m, n, p, q, sum = 0, i, j, k

Multiplication of two polynomials using linked list in java I am doing a program "Multiplication of two polynomials using linked list in java...; Node q = front; //insert in front if exponent is higher

Java String You are given two strings S1 and S2,Delete from S2 all those characters which occur in s1 also and create a clean S2 with the relevant characters deleted..write a pgm for this..pls send as soon as possible Thank you

Java String How to seperate the string into characters. there is a method called getChars() in String class,plz use that and separate into characters so plz verify the String api for related questions

]); } } } ---------------------------------------------------- I am sending simple code of String array. If you are beginner in java...String in Java hiiiii i initialise a String array,str[] with a size... in advance Hello Antony Insted Using String Array Use StringBuffer

Design and develop Multiplication table in Net beans Design and develop a program that will print a multiplication table. The program should: Ask the user for ending number than it must Display that particular multiplication

Java String In this section, you will learn about the java string. Java String is a set... to a string literal in the object stream. The Java String object contains a sequence

code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........ code for a simple java...,multiplication,division

How to split string in Java? Hi, I have a string seperated by ',' comma. How to split the string? Thanks

How to convert into to String in Java? Hi, How to convert into to String in Java? Thanks

capitalizing string in java How to capitalizing string in Java? String s = "some string"; String capitol = Character.toString(s.charAt(0)).toUpperCase(); String newString = capitol + s.substring(1,x

How to Append String In Java? How to write program in in Java for appending to a String? How to Append String In Java? What is the best way to do... the StringBuilder class. Check the example at Appending String in java. You can

Multiplication table Net Beans Using Net beans Design and develop... for ending number than Display that particular multiplication table import java.util.Scanner; class Multiplication { public static void main

number than Display that particular multiplication table import java.util.Scanner; class Multiplication { public static void main(String args...Multiplication table Using Net beans Design and develop a program

converting string to double in java Please post an example to converting string to double in java. Thanks! Convert String to Double Tutorial

for Appending String efficiently in Java. Thanks Hi, StringBuilder class of Java API is used by developers of Java for appending string... example at How To Append String In Java? Thanks

Java String Datatype Weather String in java is class or Datatype,if it's clss then How can i assign String str="hello"; String is a class found in the package java.lang.*. When we represent string in double quotes

java string vowel program java string vowel program Please visit the following links: Display the word that begins with vowel Java Count Vowels

How to append String in Java? Hi, I have a number of string in Java which is to be appended efficiently. How to append String in Java? Thanks...: str.append("India"); You check complete tutorial at Appending String in Java

java programmming: string manipulation WAP to accept a string from...' occurring in it Here is a java example that reads a string from the command prompt and find the frequency of the character e in the input string

Java String searching. How to search a string in given String array... static void main(String[] args) { String city[] = { "Delhi", "Lucknow", "Mumbai", "Kanpur" }; String userCity; Scanner scanner = new