We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,605 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how to write superscript in core java

Hi all.. I m a begginer in java... i want to write a series like 1 to the power 2, 2 to the power 3 as so on... i can print its value only line 1 , 8 , 81...
but i cant write the series where all to the power number will be in superscript order... pls can anyone help me?? here is my code where i found only the values of 1 to the power2 , 2 to the power 3....

import java.io.*;
class srs3
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int i,n,m;
        System.out.println("Enter the range:-");
        n=Integer.parseInt(br.readLine());
        System.out.println();
        System.out.println("The series upto "+n+" is: "); 
        System.out.println();       
        for(i=1;i<=n;i++)
        {
            int s=(int) Math.pow(i,(i+1));
            System.out.print(s+" ");

        }
    }
}

thanks in advance.... :)

3
Contributors
2
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
13
Views
pri.chakraborty
Newbie Poster
1 post since Feb 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

superscript in Java String

Look at the above link. It will solve your problem.

uurcnyldrm
Light Poster
26 posts since Jan 2012
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

we can achieve this by using AttributedString class which is available in java.text.*; package

the following url's may help you for this

http://www.java2s.com/Code/JavaAPI/java.text/TextAttributeSUPERSCRIPT.htm

http://www.daniweb.com/software-development/java/threads/186751/printing-powers-in-java

please check it once

radhakrishna.p
Posting Whiz in Training
272 posts since Nov 2012
Reputation Points: 29
Solved Threads: 60
Skill Endorsements: 11

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0645 seconds using 2.83MB