Share on Google+Share on Google+

Java Coder
java string multiplication
2 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

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

Ads

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);
}
}









Related Tutorials/Questions & Answers:
java string multiplication
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
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 problem - Java Beginners
Multiplication problem  I am facing a peculiar problem in java regarding a multiplication. Please see below: 19300 * 0.001 = 19.3 19400 * 0.001 = 19.400000000000002 (why is this ??) 19500 * 0.001 = 19.5 Can anybody help
multiplication algorithms in java divide and conquer
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
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
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..
java program_big digits multiplication..  i want program about big digits multiplication program using java..plz tel me answer
multiplication
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  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
code for multiplication of matrix in java using methods
code for multiplication of matrix in java using methods  code for multiplication of matrix in java using methods
Matrix Multiplication in Java
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
Multiplication of two polynomials using linked list in java
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
Matrix multiplication 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 table
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
Multiplication table
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
Multiplication table
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
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........  code for a simple java...,multiplication,division
Matrix multiplication
Matrix multiplication  program to read the elements of the given two matrices of order n*n and to perform the matrix multiplication
Java string
Java string  Strings are immutable.But String s="Hello"; String s1=s+"World"; S.O.P(s1); means printing "Hello World". How
parallel dense matrix multiplication
using dense parallel matrix multiplication. I request you to kindly provide me a code for Parallel Matrix multiplication on distributed systems using Java
Create Multiplication Table from 1 to 10
Create Multiplication Table in Java In this section, you will learn how to create multiplication table from 1 to 10. For this purpose, we have created...(String[] args) { int[][] array = new int[11][11
Java String
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
print the multiplication table up to one
Multiplication { public static void main(String args[]) { int n, c...;import java.util.Scanner; class Multiplication { public static void main(String...print the multiplication table up to one  My problem is that I have
Java String
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
Java String - Java Beginners
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 
string - Java Beginners
string in java interview questions  What is string in java? Interview questions
String in Java - Java Beginners
]); } } } ---------------------------------------------------- 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
Java string buffer
Java string buffer  what is stringBuffer and StringBuilder
How to Create Multiplication Table from 1 to 10?
How to Create Multiplication Table from 1 to 10?  Hi, I want to develop an small application store products. So, i how to create multiplication table 1 to 10. Please suggest online example related to creating multiplication
How to convert into to String in Java?
How to convert into to String in Java?  Hi, How to convert into to String in Java? Thanks
How to split string in Java?
How to split string in Java?  Hi, I have a string seperated by ',' comma. How to split the string? Thanks
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads