Ask coding questions

← Back to all posts
How do I make my out put with colour in Java?
ZacPlayz (64)

Read the title and please answer.
Who ever answers first correctly will gain 6 cycles

Answered by CodingCactus (3088) [earned 5 cycles]
View Answer
Commentshotnewtop
ZacPlayz (64)

@CodingCactus no I'm talking in Java not in Python

CodingCactus (3088)

@ZacPlayz WELL SAY THAT THEN!!!!!!!!!!

CodingCactus (3088)

@ZacPlayz how are we supposed to help if you don't even tell us what language you are using!!!

CodingCactus (3088)

@ZacPlayz it's just basic common sense, if you ask a question you need to say what language otherwise it might as well be in LOLCODE or something

ZacPlayz (64)

@CodingCactus oof I got it I wrote Java

CodingCactus (3088)

@ZacPlayz no, just Google it, it will be on Google somewhere

CodingCactus (3088)

@ZacPlayz I'm pretty sure you can use the escape codes, just use \e instead of \033

ZacPlayz (64)

@CodingCactus this is what I found.
public class Main{ public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m"; public static final String ANSI_YELLOW = "\u001B[33m"; public static final String ANSI_BLUE = "\u001B[34m"; public static final String ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m"; public static void main(String[] args) { System.out.println(ANSI_RED + "This text is red!" + ANSI_RESET); }}

put this in a java program thx for telling meh to look in Google... :D

xolyon (339)

@ZacPlayz sorry if I am late , but the ANSI codes work in Java as well it's just their excution is different

ZacPlayz (64)

@xolyon ohh its ok yeah I saw that. :D I'll still like ur comment for 1 cycle